fix for non unicode locales

This commit is contained in:
unK
2008-09-18 15:30:54 +02:00
parent 3bbe2c5054
commit ce9fed322d

View File

@@ -646,9 +646,9 @@ char * ToString(const wchar_t *ws)
string s; string s;
for (int i = 0; i < wcslen(ws); i++) for (int i = 0; i < wcslen(ws); i++)
{ {
char *c = new char[MB_CUR_MAX](); char *c = new char[MB_CUR_MAX+1]();
wctomb(c, ws[i]); if (wctomb(c, ws[i]) > 0)
s += c; s += c;
delete [] c; delete [] c;
} }
char *result = strdup(s.c_str()); char *result = strdup(s.c_str());
@@ -667,9 +667,9 @@ string ToString(const wstring &ws)
string s; string s;
for (wstring::const_iterator it = ws.begin(); it != ws.end(); it++) for (wstring::const_iterator it = ws.begin(); it != ws.end(); it++)
{ {
char *c = new char[MB_CUR_MAX](); char *c = new char[MB_CUR_MAX+1]();
wctomb(c, *it); if (wctomb(c, *it) > 0)
s += c; s += c;
delete [] c; delete [] c;
} }
return s; return s;