octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63930] fprintf problem


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #63930] fprintf problem
Date: Fri, 24 Mar 2023 20:25:55 -0400 (EDT)

Follow-up Comment #30, bug #63930 (project octave):

I rolled all the different fprintf tests in this thread into one file called
fprintf_test.m. Initially that file was ISO-8859 encoded.


$ octave --eval "__mfile_encoding__ ('latin1'), __mfile_encoding__,
fprintf_test"
ans = latin1

$ file *
01_D.txt:       ISO-8859 text
02_D.txt:       ISO-8859 text
04.txt:         ISO-8859 text, with very long lines (384), with no line
terminators
05.txt:         ISO-8859 text, with very long lines (384), with no line
terminators
06.txt:         ISO-8859 text, with very long lines (384), with no line
terminators
07.txt:         ISO-8859 text, with very long lines (384), with no line
terminators
fprintf_test.m: ISO-8859 text, with CRLF line terminators


Then I opened fprintf_test.m in a text editor and saved it as UTF-8 with Unix
line endings.


$ gedit fprintf_test.m   # saved as UTF-8 with Unix line endings

$ file *
01_D.txt:       ISO-8859 text
02_D.txt:       ISO-8859 text
04.txt:         ISO-8859 text, with very long lines (384), with no line
terminators
05.txt:         ISO-8859 text, with very long lines (384), with no line
terminators
06.txt:         ISO-8859 text, with very long lines (384), with no line
terminators
07.txt:         ISO-8859 text, with very long lines (384), with no line
terminators
fprintf_test.m: Unicode text, UTF-8 text


Now running the same command again:

$ octave --eval "__mfile_encoding__ ('latin1'), __mfile_encoding__,
fprintf_test"
ans = latin1

$ file *txt
01_D.txt: ISO-8859 text
02_D.txt: Unicode text, UTF-8 text
04.txt:   Unicode text, UTF-8 text, with very long lines (384), with no line
terminators
05.txt:   Non-ISO extended-ASCII text, with very long lines (767), with no
line terminators
06.txt:   Non-ISO extended-ASCII text, with very long lines (766), with no
line terminators
07.txt:   Non-ISO extended-ASCII text, with very long lines (765), with no
line terminators


Evidently some functions tacitly pick up on the m-file's encoding and some
don't, some give UTF-8, and some give "extended ASCII" that's not ISO or
Unicode.

Are we supposed to carry over the m-file's encoding for file operations?

Could someone test on Windows what happens to the text files when the source
file changes encoding?


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63930>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]