Linux and windows files display garbled characters

王林
Release: 2019-11-06 09:44:02
Original
3933 people have browsed it

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
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!