hello, how to convert a text file into utf-8 or utf -16 in matlab.Is there any function ?pls help me fnds..
47 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Soumya pradhan
el 25 de Feb. de 2013
Respondida: MathWorks Support Team
el 19 de Feb. de 2021
suppose a text file="hello" how it ll convert to utf-8 or utf-16
0 comentarios
Respuestas (4)
Tom Anderson
el 2 de Mayo de 2016
Editada: Tom Anderson
el 2 de Mayo de 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 comentarios
MathWorks Support Team
el 19 de Feb. de 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 comentarios
Walter Roberson
el 25 de Feb. de 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 comentarios
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!