Linux usage tips 7--GBK turn into UTF-8

Source: Internet
Author: User

Windows system editing Java source code, open in Linux will appear in the case of Chinese garbled. The reason is the file encoding format problem, under Windows is usually GBK and Linux is UTF-8.

The encoding format can be seen in Vim using the Set fileencoding command, as follows:

//linux下fileencoding=utf-8//windows下fileencoding=latin1

The easiest way to do this is to save the file in UTF8 format under Windows. Then under Linux we can use the Iconv tool to convert it into a format.

$ iconv--helpusage:iconv [OPTION ...] [FILE ...] Convert encoding of given files from one encoding to another. Input/output format Specification:-F,--from-code=NAME encoding of original text-T,--to-code=NAME encoding  for outputInformation:-L,--list list all known coded character setsOutput Control:-c omit invalid characters from output-o,--output=file output file-s,--silent suppress warnings--verbose Print Progress Information-?,--Help Give  this help list--usage Give A short usage message- V,--version Print Program version
-f-t UTF-8 test.-o test2.java

After the conversion, the Chinese garbled is gone.

Linux usage tips 7--GBK turn into UTF-8

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.