From d80578329ca2e2507f567b593883a4376544585d Mon Sep 17 00:00:00 2001 From: Wang Renxin Date: Thu, 4 Aug 2016 09:31:29 +0800 Subject: [PATCH] *improved locale processing. --- HISTORY | 3 +++ core/my_basic.c | 3 ++- shell/main.c | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index bff1875..f346e37 100755 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,6 @@ +Aug. 4 2016 +Improved locale processing + Jul. 26 2016 Fixed a multiple disposing bug with class member diff --git a/core/my_basic.c b/core/my_basic.c index ffe3773..153a726 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -15971,16 +15971,17 @@ _print: _get_printer(s)(MB_REAL_FMT, val_ptr->data.float_point); } else if(val_ptr->type == _DT_STRING) { #if defined MB_CP_VC && defined MB_ENABLE_UNICODE + char* loc = setlocale(LC_ALL, ""); char* str = val_ptr->data.string ? val_ptr->data.string : MB_NULL_STRING; _dynamic_buffer_t buf; size_t lbuf = 0; _INIT_BUF(buf); - setlocale(LC_ALL, ""); while((lbuf = (size_t)mb_bytes_to_wchar(str, &_WCHAR_BUF_PTR(buf), _WCHARS_OF_BUF(buf))) > _WCHARS_OF_BUF(buf)) { _RESIZE_WCHAR_BUF(buf, lbuf); } _get_printer(s)("%ls", _WCHAR_BUF_PTR(buf)); _DISPOSE_BUF(buf); + setlocale(LC_ALL, loc); #else /* MB_CP_VC && MB_ENABLE_UNICODE */ _get_printer(s)(val_ptr->data.string ? val_ptr->data.string : MB_NULL_STRING); #endif /* MB_CP_VC && MB_ENABLE_UNICODE */ diff --git a/shell/main.c b/shell/main.c index 925b3ac..fa4e194 100755 --- a/shell/main.c +++ b/shell/main.c @@ -757,11 +757,12 @@ static void _list_one_line(bool_t nl, long l, const char* ln) { #if defined MB_CP_VC && defined MB_ENABLE_UNICODE wchar_t wstr[16]; wchar_t* wstrp = wstr; - setlocale(LC_ALL, ""); + char* loc = setlocale(LC_ALL, ""); _bytes_to_wchar(ln, &wstrp, countof(wstr)); _printf(nl ? "%ld]%ls\n" : "%ld]%ls", l, wstrp); if(wstrp != wstr) free(wstrp); + setlocale(LC_ALL, loc); #else /* MB_CP_VC && MB_ENABLE_UNICODE */ _printf(nl ? "%ld]%s\n" : "%ld]%s", l, ln); #endif /* MB_CP_VC && MB_ENABLE_UNICODE */