diff --git a/src/lib/libast/comp/setlocale.c b/src/lib/libast/comp/setlocale.c index 65553f8bb108..013f4ef51150 100644 --- a/src/lib/libast/comp/setlocale.c +++ b/src/lib/libast/comp/setlocale.c @@ -2217,6 +2217,23 @@ iswalpha(wchar_t c) typedef int (*Isw_f)(wchar_t); +static int +wide_wctomb(char* u, wchar_t w) +{ + int size = 0; + + if (u) + { + size = wctomb(u, w); + if (size < 0) + { + *u = (char)(w & 0xff); + size = 1; + } + } + return size; +} + /* * called when LC_CTYPE initialized or changes */ @@ -2261,7 +2278,7 @@ set_ctype(Lc_category_t* cp) { if (!(ast.mb_width = wcwidth)) ast.mb_width = default_wcwidth; - ast.mb_conv = wctomb; + ast.mb_conv = wide_wctomb; #ifdef mb_state { /*