X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8d94819c437fdf28c45e9f328e6c38fd1c639ddf..d298f18ffb4bd0bd758b10f34c9e01cd119d1365:/src/common/wxcrt.cpp diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index 55ad0812a8..dc51b48e41 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -586,13 +586,20 @@ namespace #if !wxUSE_UTF8_LOCALE_ONLY int ConvertStringToBuf(const wxString& s, char *out, size_t outsize) { - const wxWX2WCbuf buf = s.wc_str(); + const wxCharBuffer buf(s.mb_str()); - size_t len = wxConvLibc.FromWChar(out, outsize, buf); - if ( len != wxCONV_FAILED ) - return len-1; - else - return wxConvLibc.FromWChar(NULL, 0, buf); + const size_t len = buf.length(); + if ( outsize > len ) + { + memcpy(out, buf, (len+1) * sizeof(char)); + } + else // not enough space + { + memcpy(out, buf, (outsize-1) * sizeof(char)); + out[outsize-1] = '\0'; + } + + return len; } #endif // !wxUSE_UTF8_LOCALE_ONLY