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: Markus Mützel
Subject: [Octave-bug-tracker] [bug #63930] fprintf problem
Date: Fri, 31 Mar 2023 09:12:43 -0400 (EDT)

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

I saved the following to `Test_encoding.m`:

disp('text mode - UTF-8')
fid = fopen('textmode_utf8.tst', 'wt', 'n', 'UTF-8');
fwrite(fid, 'ä');
fclose(fid);
fid = fopen('textmode_utf8.tst', 'rb');
fread(fid)
fclose(fid);

disp('binary mode - UTF-8')
fid = fopen('binarymode_utf8.tst', 'wb', 'n', 'UTF-8');
fwrite(fid, 'ä');
fclose(fid);
fid = fopen('binarymode_utf8.tst', 'rb');
fread(fid)
fclose(fid);

disp('text mode - Latin1')
fid = fopen('textmode_latin1.tst', 'wt', 'n', 'Latin1');
fwrite(fid, 'ä');
fclose(fid);
fid = fopen('textmode_latin1.tst', 'rb');
fread(fid)
fclose(fid);

disp('binary mode - Latin1')
fid = fopen('binarymode_latin1.tst', 'wb', 'n', 'Latin1');
fwrite(fid, 'ä');
fclose(fid);
fid = fopen('binarymode_latin1.tst', 'rb');
fread(fid)
fclose(fid);


Running it in Matlab R2022a resulted in the following:

>> Test_encoding
text mode - UTF-8

ans =

   195
   164

binary mode - UTF-8

ans =

   195
   164

text mode - Latin1

ans =

   228

binary mode - Latin1

ans =

   228

>> 


So, Matlab seems to transcode strings independent on whether a file stream was
opened in text mode or in binary mode.

Should we revert https://hg.savannah.gnu.org/hgweb/octave/rev/fcd97a68e5f7 in
favor of a different change? At least, on the default branch?
We could keep that change to mitigate the effects of this issue on the stable
branch.



    _______________________________________________________

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]