7. Linux: Garbled solutions and linux garbled Solutions

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.