I'd like to use Unicode characters if they are supported by the terminal, and fall back to ASCII characters if the user's terminal can't display them correctly. Is there any relatively easy way to do this in a shell script?
First, you're probably confusing Unicode with a particular encoding. Suppose you know that the termnal supports Unicode characters -- you still don't know how to print them!
You're probably thinking about something like UTF-8, the most popular Unicode encoding out there.
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 that case something is broken on user's side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With