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