Home > Software design >  Bash equivalent to python "unicodedata.name"?
Bash equivalent to python "unicodedata.name"?

Time:03-23

is there an equivalent to python "unicodedata.name" in bash, maybe a linux file with letter names? Is it possible to convert an "L" to "LATIN CAPITAL LETTER L" with iconv?

Thanks for help

import unicodedata; print (unicodedata.name("L"))

If an equivalent in iconv exists I don't know which is the right one. Wanted instead of "L" as issue "LATIN CAPITAL LETTER L".

echo -e "L" | iconv -f UTF-8 -t UNICODELITTLE//TRANSLIT

CodePudding user response:

Using a perl one-liner:

$ perl -CA -Mcharnames=\(\) -E 'say charnames::viacode(ord $ARGV[0])' L
LATIN CAPITAL LETTER L

Or with python:

$ python3 -c 'import sys, unicodedata; print(unicodedata.name(sys.argv[1][0]))' L
LATIN CAPITAL LETTER L

CodePudding user response:

Thank, but I thought there might be a more direct way.

If I convert a code into a string and load it from another file and execute with eval, a bash script would be even more complicated. And then I also have additional problems with the quotation marks and clinging and so on.

  • Related