fixed another bug in strconv

(Off by one error that did not demonstrate itself in poEdit before because
windows native convertion wasn't used due to wxLocale returning cp12xx instead
of windows-12xx. MultiByteToWideChar and WideCharToMultiByte return size of
needed buffer, not number of output characters. Author of the code didn't know
this, hence off by one.)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10557 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2001-06-12 22:56:40 +00:00
parent 93a20a27c3
commit 35d764b08c

View File

@@ -627,14 +627,18 @@ public:
{
size_t len =
MultiByteToWideChar(CodePage, 0, psz, -1, buf, buf ? n : 0);
return len ? len : (size_t)-1;
//VS: returns # of written chars for buf!=NULL and *size*
// needed buffer for buf==NULL
return len ? (buf ? len : len-1) : (size_t)-1;
}
size_t WC2MB(char *buf, const wchar_t *psz, size_t n)
{
size_t len = WideCharToMultiByte(CodePage, 0, psz, -1, buf,
buf ? n : 0, NULL, NULL);
return len ? len : (size_t)-1;
//VS: returns # of written chars for buf!=NULL and *size*
// needed buffer for buf==NULL
return len ? (buf ? len : len-1) : (size_t)-1;
}
bool usable()