Mercurial > octave
changeset 31946:0ed6d1f01625 stable
fopen: Use "UTF-8" as default encoding for fopen (bug #63930).
* file-io.cc (Ffopen): Default to no conversion between Octave's internal
representation of char arrays and the output stream (i.e., UTF-8). That is
compatible to latest versions of Matlab. And it will help to mitigate issues
when transcoding non-ASCII characters in streams when they are opened without
specifying an encoding.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 31 Mar 2023 18:05:48 +0200 |
parents | c687e0ba6606 |
children | 89850bb5eb31 ba7761c84597 |
files | libinterp/corefcn/file-io.cc |
diffstat | 1 files changed, 2 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc Fri Mar 31 17:25:29 2023 +0200 +++ b/libinterp/corefcn/file-io.cc Fri Mar 31 18:05:48 2023 +0200 @@ -500,8 +500,7 @@ character string that specifies whether the file is to be opened for reading, writing, or both. The @var{encoding} is a character string with a valid encoding identifier. This encoding is used when strings are read from -or written to the file. By default, the same encoding specified for reading -@file{.m} files is used for interpreting user files. +or written to the file. By default, that is UTF-8. The second form of the @code{fopen} function returns a vector of file ids corresponding to all the currently open files, excluding the @@ -624,8 +623,7 @@ octave_value arch = (nargin > 2) ? args(2) : octave_value ("native"); input_system& input_sys = interp.get_input_system (); - octave_value encoding = (nargin > 3) ? args(3) - : octave_value (input_sys.mfile_encoding ()); + octave_value encoding = (nargin > 3) ? args(3) : octave_value ("utf-8"); if (encoding.string_value () == "system") encoding = octave_value (octave_locale_charset_wrapper ());