开发者

Is there anyway for a bash (or any other shell) script to detect whether the current terminal supports unicode characters?

I'd like to use Unicode ch开发者_开发百科aracters 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.


In script print

:set encoding=utf-8

If you want your terminal support unicode, become new terminal with -u8 option

type in terminal xterm -u8

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜