(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
{
size_t len =
MultiByteToWideChar(CodePage, 0, psz, -1, buf, buf ? n : 0);
{
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);
}
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;