Format transformation in .txt

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

Walter Roberson
Walter Roberson 2019년 10월 29일
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
Sergio Vez 2019년 10월 30일
Not the same. I need the output file to have the same UNIX(LF) and UTF-16 LE like the imput file. I send you the program I have.
  • In order to do proper changes I first delete the paragraph sign in MATLAB
  • But then, I need to put it again but it only recognizes it as a symbol and not as a paragraph sign
  • So then when I use the output file in another software it doesn't read it completly
  • I guess it has something to do with the difference between UNIX(LF)/UTF-16 (input) vs. WINDOWS(CRLF)/UTF-8 (output).
Any idea on how to solve this?
Big thanks!
Sergio Vez
Sergio Vez 2019년 10월 30일
Forgot to attach
Sergio Vez
Sergio Vez 2019년 10월 31일
Any idea?
Thanks!
Walter Roberson
Walter Roberson 2019년 10월 31일
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
Sergio Vez 2019년 10월 31일
This is the real imput file. In (.Z14). I made a mistake sending it in (.txt)
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
Sergio Vez 2019년 11월 4일
Thank you so much! It worked!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2019년 10월 29일

댓글:

2019년 11월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by