Is there any script for bash (or any other shell) to determine if the current terminal supports Unicode characters?

I would like to use Unicode characters if supported by the terminal, and return to ASCII characters if the user terminal cannot display them correctly. Is there a relatively easy way to do this in a shell script?

+7
source share
2 answers

First, you are probably confusing Unicode with a specific encoding. Suppose you know that termnal supports Unicode characters - you still don't know how to print them!

You are probably thinking of something like UTF-8, the most popular Unicode encoding.

To get the encoding of the current locale, use

locale charmap 

This is the encoding of the current locale, and theoretically it may differ from the encoding used by the terminal, but in this case something is violated on the user side.

+3
source

Print to script

: set encoding = utf-8

If you want your terminal to support Unicode, become a new terminal with the -u8 option

enter terminal xterm -u8

-one
source

All Articles