hello, how to convert a text file into utf-8 or utf -16 in matlab.Is there any function ?pls help me fnds..
63 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
suppose a text file="hello" how it ll convert to utf-8 or utf-16
0 Kommentare
Antworten (4)
Tom Anderson
am 2 Mai 2016
Bearbeitet: Tom Anderson
am 2 Mai 2016
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 Kommentare
MathWorks Support Team
am 19 Feb. 2021
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 Kommentare
Walter Roberson
am 25 Feb. 2013
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 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!