Whatsit Asked: 2009-05-29 07:47:34 +0800 CST2009-05-29 07:47:34 +0800 CST 2009-05-29 07:47:34 +0800 CST How to find out if a terminal supports UTF-8 772 I'm setting up the CPAN module for perl on CentOs 5, and one of the questions is 'Does your terminal support UTF-8?' (paraphrased). How do I find out? terminal utf-8 7 Answers Voted user9474 2012-08-07T10:39:45+08:002012-08-07T10:39:45+08:00 Type this in your terminal: echo -e '\xe2\x82\xac' If your terminal supports UTF-8 it will output the euro sign: € Best Answer theman_on_osx 2009-05-29T07:58:48+08:002009-05-29T07:58:48+08:00 Really, the surefire way to test is to download a text file and cat it in the terminal and see if everything looks ok. or, if you can, recompile the terminal enabling the unicode option (assuming it has one). what does $TERM and $LANG look like? therek 2009-05-29T08:04:53+08:002009-05-29T08:04:53+08:00 The lamest way: run following and check the output. It will be a capital O with circumflex if the terminal displays UTF-8. perl -le 'print "\x{c3}\x{94}"' Scott Pack 2009-05-29T10:17:04+08:002009-05-29T10:17:04+08:00 The most sure fire way is to use the ‘locale’ command. It will print out all the various and sundry variables that dictate what character set to use. For instance, this is my output on RHEL5.3, set to only use UTF-8 by default. LANG="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_CTYPE="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_ALL= ss32 2011-07-05T06:28:26+08:002011-07-05T06:28:26+08:00 You may just use the following command: locale charmap Janus Troelsen 2014-12-26T02:42:40+08:002014-12-26T02:42:40+08:00 curl http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt or wget -O - http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt This obviously requires wget or curl. computermite 2012-06-20T15:44:08+08:002012-06-20T15:44:08+08:00 UTF=$(echo -e "\u263A") if [[ ! "$UTF" =~ "A" ]] ; then echo -n "UNICODE here!" fi
Type this in your terminal:
If your terminal supports UTF-8 it will output the euro sign:
Really, the surefire way to test is to download a text file and cat it in the terminal and see if everything looks ok.
or, if you can, recompile the terminal enabling the unicode option (assuming it has one).
what does $TERM and $LANG look like?
The lamest way: run following and check the output. It will be a capital O with circumflex if the terminal displays UTF-8.
The most sure fire way is to use the ‘locale’ command. It will print out all the various and sundry variables that dictate what character set to use. For instance, this is my output on RHEL5.3, set to only use UTF-8 by default.
You may just use the following command:
or
This obviously requires
wget
orcurl
.