From ce9fed322dee9420164d1b67815470b534e27582 Mon Sep 17 00:00:00 2001 From: unK Date: Thu, 18 Sep 2008 15:30:54 +0200 Subject: [PATCH] fix for non unicode locales --- src/window.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/window.cpp b/src/window.cpp index b18c6e73..499822cf 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -646,9 +646,9 @@ char * ToString(const wchar_t *ws) string s; for (int i = 0; i < wcslen(ws); i++) { - char *c = new char[MB_CUR_MAX](); - wctomb(c, ws[i]); - s += c; + char *c = new char[MB_CUR_MAX+1](); + if (wctomb(c, ws[i]) > 0) + s += c; delete [] c; } char *result = strdup(s.c_str()); @@ -667,9 +667,9 @@ string ToString(const wstring &ws) string s; for (wstring::const_iterator it = ws.begin(); it != ws.end(); it++) { - char *c = new char[MB_CUR_MAX](); - wctomb(c, *it); - s += c; + char *c = new char[MB_CUR_MAX+1](); + if (wctomb(c, *it) > 0) + s += c; delete [] c; } return s;