hello, how to convert a text file into utf-8 or utf -16 in matlab.Is there any function ?pls help me fnds..
57 次查看(过去 30 天)
显示 更早的评论
suppose a text file="hello" how it ll convert to utf-8 or utf-16
0 个评论
回答(4 个)
Tom Anderson
2016-5-2
编辑:Tom Anderson
2016-5-2
In Windows, the MATLAB Editor/Debugger does not currently (as of 2016) save in UTF-8, but in ANSI. It will actually load a UTF-8 file but if it's saved, the encoding is changed to ANSI. And it appears that this is the way it will be for some time to come. There are hints that the Mac version will allow saving .m files in UTF-8 in the 2016 release notes, but for now they are not saying anything firm about when they will make this change for Windows. As far as I can tell, UTF-8 is now (since 2014) supported in every other area of MATLAB, from Figures to the GUI.
Just not in saving files in the editor. But keep your eyes open; One day, in keeping in this unicode internationalisation trend, maybe in the next decade or two, Mathworks might also allow the editor to save in UTF-8 or unicode format under Windows.
Note that this is what I heard from Mathworks product support on this issue: "I am writing in reference to your Technical Support Case #01940322 regarding 'Editor/Debugger can't save in UTF-8 format'. Thank you for your email. Our developer are aware of this behavior and they may incorporate this in any future release of MATLAB."
0 个评论
MathWorks Support Team
2021-2-19
As of R2020a, MATLAB defaults to saving new plain text files using UTF-8. You can select a different encoding with the Save As dialog.
As of R2020a, UTF-16 (LE and BE) is also supported, but the encoding must be specified when writing a file:
fid = fopen('utf16_file.txt', 'w', 'n', 'utf-16le')
When opening existing files, the Editor and functions like type or fopen automatically determine the current encoding.
0 个评论
Walter Roberson
2013-2-25
When you fopen() a text file you can specify the character set encoding you want it to be written in.
Sometimes it turns out to be necessary to work with unicode2native() or native2unicode()
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!