how to set the encoding of MATLAB m-files to be UTF8
184 views (last 30 days)
Show older comments
I want to insert an m-file into LaTeX, and there are Chinese characters in my m-files, so I need the encoding of m-files to be UTF8.I have searched for some materials on the web, and I found the MATLAB command: slCharacterEncoding. So, I closed all the m-files and input the" slCharacterEncoding('UTF-8') "in the command window. But when I opened the m-file using Notepad++, the encoding with Chinese characters still is GB2312, and the m-files without Chinese characters is normal (UTF8).
how should I do to set the matlab editor to be UTF8 encoding? thanks
0 Comments
Answers (2)
Image Analyst
on 27 Sep 2019
Maybe open the file for reading, then open a file for writing using fopen(filename, , wt, 'UTF-8') (not sure if there is a parameter name that goes before UTF-8 so check the documentation. Then read from one file and write to the output file.
MathWorks Support Team
on 19 Feb 2021
Edited: MathWorks Support Team
on 19 Feb 2021
As of R2020a, the MATLAB Editor will default to saving new files using UTF-8. When opening existing files, the Editor and other functions like type or fopen automatically determine the current encoding. One can explicitly specify that the file should be saved using UTF-8 using the Save As dialog.
0 Comments
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!