Code: Select all
#!/bin/bash
:<<INTRO
dhm, Oct'15.
Note: The Unicode escapes are not documented in the (c) 2014 man file
which was distributed with the March 2015 GNU coreutils 8.23.
This is therefore a bug in GNU and Debian.
The undocumented syntax where xxxx or xxxxx is a hexadecimal is:
echo -e \uxxxx for a 4 digit hex number only (obsolete)
echo -e \Uxxxx
echo -e \Uxxxxx for a 4 or 5 digit hex number
There are a bunch of "fonts" in Unicode which are not conventional fonts but
are mathematical symbols for algebra and science when the Latin and Greek
alphabets are not enough.
I have occasionally downloaded extra stuff for no special reasoning so I
don't know if these math symbols are default with Debian.
The current version of tr (8.23) cannot translate a Unicode sequence and I
don't know if it can even handle the accented characters of non-English
alphabets much less transliterate Greek or Cyrillic.
INTRO
declare -ar AlphaPlain=({A..Z} {a..z})
declare -r UnicodeFraktur=0x1D56C
declare -a AlphaFraktur
FrakturLoad(){
local -i j k n
local C X
for (( k=0; k<52; k++ )); do
(( n=UnicodeFraktur+k ))
X="\U"`printf %x $n`
C=`echo -e $X`
AlphaFraktur[k]=$C
done
} # FrakturLoad
FrakturTranslate(){
local Input=$1
local -i i k n Len found
local A C X
Len=${#Input}
for (( i=0; i<Len; i++ )); do
C=${Input:i:1}
found=0
for (( k=0; k<52; k++ )); do
[[ $C == ${AlphaPlain[k]} ]] && { found=1; break; }
done
if (( found==1 )); then
C=${AlphaFraktur[k]}
fi
A+=$C
done
echo $A
} #FrakturTranslate
# #################### MAINLINE ###############################
Skull=`echo -e "\U2620"` # Skull and Crossbones in Unicode
for ((k=0; k<20; k++ )); do
SkullLine+=$Skull" "
done
FrakturLoad
Str1=`FrakturTranslate "Trick or Treat"`
Str2=`FrakturTranslate "for"`
Str3=`FrakturTranslate "Halloween"`
clear
echo $SkullLine
echo -e "\t"$Str1
echo -e "\t"$Str2
echo -e "\t"$Str3
echo $SkullLine