txt looks normal on Linux but weird on Windows. WHY?

조회 수: 4 (최근 30일)
Alex
Alex 2013년 6월 24일
댓글: Stephen23 2022년 3월 5일
I created txt. file using fopen, fwrite and fclose running MATLAB on Linux. However, the lines are mixed up when opening the file on Windows. Is there any work around? I need to be able to work with the txt. file on both WIndows and Linux.
  댓글 수: 1
Titus Edelhofer
Titus Edelhofer 2013년 6월 24일
What do you mean by mixed up? Wrong order? Or no line breaks?

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

채택된 답변

Walter Roberson
Walter Roberson 2013년 6월 24일
On the Linux side, each place that you currently write out '\n', change it to '\r\n'. That is, instead of char(10) use char([13 10])

추가 답변 (1개)

Jan
Jan 2013년 6월 24일
What does "opening the file in Windows" exactly mean? While all editors I know, even vi, XEmacs on Windows, MS Word Alpha on my old MacOS-8 computer and the preview on LCD of the fancy Ricoh printer handle Linux/Windows linebreaks correctly, Window's Notepad fails. If you mean this limitations of Notepad, I share your curiosity: Why does Microsoft ships such a bad program with Windows?
Btw. I did not test this in Windows8 yet.

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by