First, the reason for garbled characters
Garbled code is caused by a non-uniform, there are some places to pay attention to
1. Linux system default supported language data: This is related to/etc/sysconfig/i18n;
2. Your terminal interface (BASH) language: This is related to LANG's variable;
3. The original encoding of your file; Use the file command to view
4. The software that opens the terminal, such as the window interface under GNOME.
Second, DOS and UNIX under the conversion of documents
Dos and UNIX under the different definition of line, DOS is \ r \ n, Unix is \ n
Dos2unix [-kn] file [NewFile]
Unix2dos [-kn] file [NewFile]
Options and Parameters:
-K: Retains the original mtime time format of the file (does not update the file last modified time)
-N: Preserves the original old file, outputs the converted content to the new file,
Third, the Code conversion
Iconv--list
Iconv-f Original code-t new code filename [-o newfile]
Options and Parameters:
--list: List of language data supported by Iconv
-f:from, the original encoding format;
-t:to, new encoding format;
-O File: If you want to keep the original file, use the-o new file name to create a new encoded file.
Linux Learning seven-garbled solution