简而言之:如何向终端显示未以 UTF-8 编码的文件?
目前,我有一个以 ISO-8859-9 编码并包含以下 12 个字符的测试文件:
ğüşıöçĞÜŞİÖÇ
文件的十六进制内容如下:
\F0\FC\FE\FD\F6\E7\D0\DC\DE\DD\D6\C7
当我尝试将此文件显示到终端时,我得到:
������������
我想这是因为,我当前的语言环境是这样定义的:
$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_GB.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_GB.UTF-8
LC_NAME=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
LC_TELEPHONE=en_GB.UTF-8
LC_MEASUREMENT=en_GB.UTF-8
LC_IDENTIFICATION=en_GB.UTF-8
LC_ALL=
但是,我在系统中安装了土耳其语语言环境:
$ locale -a
C
C.UTF-8
en_GB
en_GB.iso88591
en_GB.iso885915
en_GB.utf8
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
POSIX
tr_TR
tr_TR.iso88599
tr_TR.utf8
turkish
所以,我想用以下方式临时更改显示语言:
$ export LC_ALL=tr_TR.iso88599
$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="tr_TR.iso88599"
LC_NUMERIC="tr_TR.iso88599"
LC_TIME="tr_TR.iso88599"
LC_COLLATE="tr_TR.iso88599"
LC_MONETARY="tr_TR.iso88599"
LC_MESSAGES="tr_TR.iso88599"
LC_PAPER="tr_TR.iso88599"
LC_NAME="tr_TR.iso88599"
LC_ADDRESS="tr_TR.iso88599"
LC_TELEPHONE="tr_TR.iso88599"
LC_MEASUREMENT="tr_TR.iso88599"
LC_IDENTIFICATION="tr_TR.iso88599"
LC_ALL=tr_TR.iso88599
$ cat a.txt
������������
但是,我仍然得到问号。