Home >Operation and Maintenance >Linux Operation and Maintenance >Linux and windows files display garbled characters
Question:
Copy the code (.m) file written in matlab under Windows to Linux (Ubuntu), and the comments are in Chinese It's all gibberish.
Reason:
The default encoding under Windows is GB2312, and the default encoding under Linux is UTF-8. Therefore, the code generated under Windows is GB2312 encoding, which is of course recognized as garbled code under Linux; conversely, the code is garbled in the same way.
Solution:
Use the iconv command under linux to change the encoding of the file:
test1.m is converted from GB2312 to UTF-8 (windows The code of matlab under linux runs under linux)
iconv -f GB2312 -t UTF-8 test1.m -o test1.m
test2.m is converted from UTF-8 to GB2312 (the code of matlab under linux runs under windows)
iconv -f UTF-8 -t GB2312 test2.m -o test2.m
Recommended tutorial: linux tutorial
The above is the detailed content of Linux and windows files display garbled characters. For more information, please follow other related articles on the PHP Chinese website!