# HG changeset patch # User Markus Mützel # Date 1645979030 -3600 # Sun Feb 27 17:23:50 2022 +0100 # Node ID dca69d85ddb8cef489f5c946586771c7066d77b7 # Parent 76398dfe2d55300c0af22c636ad02dab1d9d7426 Test. Do not merge!!! diff -r 76398dfe2d55 -r dca69d85ddb8 libinterp/corefcn/pr-output.cc --- a/libinterp/corefcn/pr-output.cc Sun Feb 27 14:44:00 2022 +0100 +++ b/libinterp/corefcn/pr-output.cc Sun Feb 27 17:23:50 2022 +0100 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -3366,6 +3367,18 @@ return retval; } +template +struct deletable_facet : Facet +{ + template + deletable_facet (Args&& ...args) + : Facet (std::forward (args)...) + {} + + // destructor needs to be public + ~deletable_facet () {} +}; + DEFMETHOD (fdisp, interp, args, , classes: cell char double function_handle int8 int16 int32 int64 logical single struct uint8 uint16 uint32 uint64 doc: /* -*- texinfo -*- @@ -3399,10 +3412,20 @@ std::ostream *osp = os.output_stream (); - octave_value arg = args(1); - if (osp) - arg.print (*osp); + { + octave_value arg = args(1); + + if (os.encoding ().compare ("utf-8")) + { + typedef deletable_facet> convfacet_t; + std::wbuffer_convert conv_out (osp->rdbuf (), new convfacet_t (os.encoding ())); + std::ostream osp_conv (&conv_out); + arg.print (osp_conv); + } + else + arg.print (*osp); + } else error ("fdisp: stream FID not open for writing");