Mercurial > octave
changeset 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 | a9de8cde1b22 |
children | efaaf58c8d07 |
files | libinterp/corefcn/interpreter.cc oct-conf-post.in.h |
diffstat | 2 files changed, 14 insertions(+), 3 deletions(-) [+] |
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");
--- a/oct-conf-post.in.h Sat Nov 20 18:52:33 2021 +0100 +++ b/oct-conf-post.in.h Sun Nov 21 15:25:04 2021 +0100 @@ -155,6 +155,12 @@ # define OCTAVE_HAVE_POSIX_FILESYSTEM 1 #endif +/* assume that Windows will support UTF-8 locales when using UCRT */ +#if defined (__MSVCRT_VERSION__) && __MSVCRT_VERSION__ == 0x0E00 +# define OCTAVE_HAVE_WINDOWS_UTF8_LOCALE +#endif + + /* sigsetjmp is a macro, not a function. */ #if defined (sigsetjmp) && defined (HAVE_SIGLONGJMP) # define OCTAVE_HAVE_SIG_JUMP 1