How to make special characters in Bash script for conky?

I wonder how I can create a Celsius symbol in my bash script, so I could fix the output in the string "CPU temp: 50 C"? What are the escape sequences for these kind of special characters if my font supports them?

Scratching my head ...

To be more precise, I need to use it in conky. I use this line: awk '{printf ($ 3 "C")}'. How to fix it so that it gives out degrees Celsius? The reason is if I insert the symbol directly, conky its screws.

+5
source share
3 answers

All uncontrolled byte sequences of your script output to the terminal are interpreted for display in accordance with the terminal settings. If you configure it to interpret the input as utf-8 , then all you need to do in the bash script prints the Celsius character, as utf-8 requires .

Setting the right to the terminal depends on the application you are using. It is likely that it is already in utf-8 mode.

To display the character you need, you need to find its Unicode encoding code and encode it in utf-8, or you can find it somewhere where the utf-8 character sequence is already shown. The Celsius symbol is described here , for example.

celsius utf-8 0xE2 0x84 0x83, $'string', escape \xhh:

$ echo $'\xe2\x84\x83'

-e:

$ echo -e '\xe2\x84\x83'

,

$ CEL=$'\xe2\x84\x83'
$ echo $CEL

℃ : C, :

$ echo $'\xc2\xb0'C
°C

, $'string', , perl python:

$ python -c 'print "\xe2\x84\x83"'
$ perl -e 'print "\xe2\x84\x83\n"'

GNU awk escape- C, \xhh, :

$ awk 'BEGIN { print "\xe2\x84\x83"; }' 
$ awk 'BEGIN { print "\xc2\xb0\C"; }' 
°C

, ( escape- , C, . GNU awk).

awk - . 0xC2 302 0xB0 260, :

$ awk 'BEGIN { print "\302\260C"; }'
°C

,

$ awk 'BEGIN { print "\342\204\203"; }'
+8

escape- °.

0

:

echo -e "CPU temp: 50\xE2\x84\x83"

: 4- Unicode Bash?

0

All Articles