X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/14c90e0074aa2a5eb7a009d356a8181475ee7233..d0af5538d676fdc5f7620233ee24f43832b80bff:/src/common/strconv.cpp diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index c0c44bb58a..8d27a4dd24 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -97,7 +97,7 @@ WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc; #ifdef WC_UTF16 -static size_t encode_utf16(wxUint32 input, wxUint16 *output) +static size_t encode_utf16(wxUint32 input, wchar_t *output) { if (input<=0xffff) { @@ -119,7 +119,7 @@ static size_t encode_utf16(wxUint32 input, wxUint16 *output) } } -static size_t decode_utf16(const wxUint16* input, wxUint32& output) +static size_t decode_utf16(const wchar_t* input, wxUint32& output) { if ((*input<0xd800) || (*input>0xdfff)) { @@ -357,7 +357,7 @@ size_t wxMBConvUTF8::WC2MB(char *buf, const wchar_t *psz, size_t n) const { wxUint32 cc; #ifdef WC_UTF16 - size_t pa = decode_utf16(psz,cc); + size_t pa = decode_utf16(psz, cc); psz += (pa == (size_t)-1) ? 1 : pa; #else cc=(*psz++) & 0x7fffffff; @@ -418,7 +418,7 @@ static long CharsetToCodepage(const wxChar *name) path += cn; wxRegKey key(wxRegKey::HKCR, path); - if (!key.Exists()) continue; + if (!key.Exists()) break; // two cases: either there's an AliasForCharset string, // or there are Codepage and InternetEncoding dwords. @@ -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()