Mercurial > octave
diff libinterp/corefcn/interpreter.cc @ 30309:bf619727bf6c
interpreter: Use UTF-8 locale on Windows if possible.
* libinterp/corefcn/interpreter.cc (interpreter::interpreter): Force a UTF-8
locale on Windows if possible.
* oct-conf-post.in.h (OCTAVE_HAVE_WINDOWS_UTF8_LOCALE): Assume that Windows will
support UTF-8 locales when using UCRT.
See also: https://octave.discourse.group/t/1821
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 21 Nov 2021 15:25:04 +0100 |
parents | c8d5ec1f5618 |
children | efaaf58c8d07 |
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc Sat Nov 20 18:52:33 2021 +0100 +++ b/libinterp/corefcn/interpreter.cc Sun Nov 21 15:25:04 2021 +0100 @@ -495,10 +495,15 @@ m_instance = this; +#if defined (OCTAVE_HAVE_WINDOWS_UTF8_LOCALE) + // Force a UTF-8 locale on Windows if possible + std::setlocale (LC_ALL, ".UTF8"); +#else + std::setlocale (LC_ALL, ""); +#endif // Matlab uses "C" locale for LC_NUMERIC class regardless of local setting - setlocale (LC_ALL, ""); - setlocale (LC_NUMERIC, "C"); - setlocale (LC_TIME, "C"); + std::setlocale (LC_NUMERIC, "C"); + std::setlocale (LC_TIME, "C"); sys::env::putenv ("LC_NUMERIC", "C"); sys::env::putenv ("LC_TIME", "C");