[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #61839] fputs() + fdisp() do not use the fopen
From: |
qx1147 |
Subject: |
[Octave-bug-tracker] [bug #61839] fputs() + fdisp() do not use the fopen() character encoding |
Date: |
Mon, 17 Jan 2022 06:32:00 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0 |
URL:
<https://savannah.gnu.org/bugs/?61839>
Summary: fputs() + fdisp() do not use the fopen() character
encoding
Project: GNU Octave
Submitted by: qx1147
Submitted on: Mon 17 Jan 2022 11:31:58 AM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: qx1147
Originator Email:
Open/Closed: Open
Release: 7.0.90
Discussion Lock: Any
Operating System: Microsoft Windows
_______________________________________________________
Details:
Different to fprintf(), fputs() + fdisp() do not use the fopen() character
encoding (or the editor's default encoding as set in the Octave's editor
preferences). Instead, these functions pass on the internal UTF-8 encoding (at
least with Windows, did not test with Linux).
The following code:
str = '20°C';
fid = fopen('dummy.txt', 'wt', 'n', 'ISO-8859-1');
fprintf(fid,'%s\n', str);
fdisp(fid,str);
fputs(fid,str);
fclose(fid);
Produces the following text file (ISO-encoded):
20°C
20°C
20°C
The two last lines interpreted as UTF-8 (the first line is no valid UTF-8):
20°C
20°C
Note that for fprintf(), it does not matter whether the string is formatted or
passed directly, i.e., fprintf(fid,str) also uses the correct encoding.
[Win10-21H2, Octave 6.2 or 7.0.90]
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61839>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #61839] fputs() + fdisp() do not use the fopen() character encoding,
qx1147 <=