Format transformation in .txt
Mostrar comentarios más antiguos
Good afternoon,
I made a MATLAB program that enters a ".txt" file, makes some changes on it, and outputs the same ".txt" file with the changes.
The problem is that the IMPUT ".txt" uses a conversion UNIX(LF) and a unicode transformation format UTF-16 LE. But the OUTPUT ".txt" is created by MATLAB with a conversion WINDOWS(CRLF) and an unicode transformation format UTF-8. That makes some symbols or the newline parameter not to be read properly.
How could I fix it?
Thanks in advanced
Sergio
9 comentarios
Walter Roberson
el 29 de Oct. de 2019
If this is the same as your earlier question, the only input character that was non-ASCII was the paragraph symbol, char(182) . UTF encoding is not necessary in that case. Would it be acceptable to write it out without UTF encoding?
Sergio Vez
el 30 de Oct. de 2019
Sergio Vez
el 30 de Oct. de 2019
Sergio Vez
el 31 de Oct. de 2019
Walter Roberson
el 31 de Oct. de 2019
The file is not UTF16-LE . It is also not provably UTF-8 but it might be. It is CR+LF delimited (not LF only) lines with a maximum byte value of 182, which is the paragraph symbol.
Sergio Vez
el 31 de Oct. de 2019
Sergio Vez
el 31 de Oct. de 2019
Walter Roberson
el 31 de Oct. de 2019
fileID = fopen('ENTRADA.Z14','rt','n','UTF16-LE');
and on output,
fileID = fopen('OUTPUT.txt', 'wt', 'n', 'UTF16-LE');
ignore the warnings about UTF16-LE not being supported.
There is a way to avoid having the warning generated (rather than ignored) but it involves doing unicode to native transformation. Not impossible by any means, but a bit of a nuisance.
Sergio Vez
el 4 de Nov. de 2019
Respuestas (0)
Categorías
Más información sobre Standard File Formats en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!