changeset 30787:76398dfe2d55

fputs: Use character encoding of file stream (bug #61839). * libinterp/corefcn/oct-stream.cc (base_stream::puts): Convert to encoding that was selected when opening the file stream.
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 27 Feb 2022 14:44:00 +0100
parents ba07f81c8480
children c11d34f72b3c
files libinterp/corefcn/oct-stream.cc
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc	Sun Feb 27 13:36:58 2022 +0100
+++ b/libinterp/corefcn/oct-stream.cc	Sun Feb 27 14:44:00 2022 +0100
@@ -6045,7 +6045,10 @@
       {
         std::ostream& os = *osp;
 
-        os << s;
+        if (encoding ().compare ("utf-8"))
+          os << string::u8_to_encoding (who, s, encoding ());
+        else
+          os << s;
 
         if (! os)
           error (who, "write error");