Linux differs from Windows system language encoding
Under the Linux operating system, we sometimes open the TXT file under Windows, and found that the TXT file that can be displayed normally in Windows is garbled in Chinese.
This occurs because of the difference between the Chinese characters encoding (compression) of two operating systems, where the character encoding is generally GBK in the Windows environment, and UTF8 in the Linux environment, This led to the normal display of TXT files under Windows in Linux environment open rendered garbled state.
System Encoding Settings
locale.genFile
# /etc/locale.gen: list all of the locales you want to have on your system## The format of each line:# <locale> <charmap>## where <locale> is a locale located in /usr/ Share/i18n/locales/ and# where <charmap> is a charmap located in /usr/share/i18n/charmaps/.## all blank lines and lines starting with # are ignored.## For the default list of supported Combinations, see the file:# /usr/share/i18n/supported## whenever glibc is emerged, the locales listed here will be automatically# rebuilt for you. after updating this file, you can simply run ' Locale-gen ' # yOurself instead of re-emerging glibc.en_us. Utf-8 utf-8zh_cn. Utf-8 utf-8
Gentoo ~ # Ls/usr/share/i18n/locales/en_us EN_GB en_hk zh_cn zh_tw zh_hkja_jp de_de .... .. Gentoo ~ #
View character encoding compression methods
/usr/share/i18n/charmaps/The directory contains the system-supported character encoding method
ls /usr/share/i18n/charmaps/ansi_x3.110-1983.gz ibm1026.gz iso-8859-16.gzansi_x3.4-1968.gz ibm1047.gz ISO_8859-1,GL.gzARMSCII-8.gz IBM1124.gz Iso-8859-1.gzasmo_449.gz ibm1129.gz ISO-8859-2.gzGB18030.gz isiri-3342.gz sami.gzgb_ 1988-80.gz iso_10367-box.gz Sami-ws2.gzgb2312.gz iso_ 10646.gz sen_850200_b.gzgbk.gz ISO_11548-1.gz SEN_850200_C.HP-ROMAN9.gz ISO_6937.gz utf-8.gz ...
Solution Solutions
Use the iconv command for file encoding conversion, such as garbled file name Hello.txt, then enter the following command in the terminal:
Iconv-f gbk-t UTF8 hello.txt > Hello.utf8.txt
This article from "Bo Master: Lone King" blog, please be sure to keep this source http://aceking.blog.51cto.com/3681913/1721597
Gentoo open windows TXT file Chinese garbled problem