7. Linux: Garbled solutions and linux garbled Solutions
I. Reasons for garbled characters
Garbled characters are caused by inconsistent encoding. Note the following:
1. Default supported language data in Linux: this is related to/etc/sysconfig/i18n;
2. The language of your terminal interface (bash): This is related to the LANG variable;
3. The original file code can be viewed using the file command.
4. Enable the terminal software, such as the window interface under GNOME.
Ii. Conversion of documents in dos and unix
Different line breaks are defined in dos and unix. in dos, they are \ r \ n, and in unix, they are \ n.
Dos2unix [-kn] file [newfile]
Unix2dos [-kn] file [newfile]
Options and parameters:
-K: Retain the original mtime format of the file (the time when the file was last modified is not updated)
-N: Retain the original archive and output the converted content to the new archive,
Iii. encoding conversion
Iconv -- list
Iconv-f original encoding-t new encoding filename [-o newfile]
Options and parameters:
-- List: Lists data of languages supported by iconv.
-F: from, the original encoding format;
-T: to, new encoding format;
-O file: whether to retain the original file. You can use the-o new file name to create a new encoding file.