X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eec47cc6c45a2d9a474cae9da897ebfdb0b7be21..a3669332df65cfae18e7540a267bc3400a64aa09:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 4e128a124f..aa039f976b 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -1006,20 +1006,14 @@ int STRINGCLASS::compare(size_t nStart, size_t nLen, #if wxUSE_UNICODE // from multibyte string -wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength) +wxString::wxString(const char *psz, const wxMBConv& conv, size_t nLength) { // anything to do? if ( psz && nLength != 0 ) { if ( nLength == npos ) { - nLength = (size_t)-1; - } - else if ( nLength == length() ) - { - // this is important to avoid copying the string in cMB2WC: we're - // already NUL-terminated so we can pass this NUL with the data - nLength++; + nLength = wxNO_LEN; } size_t nLenWide; @@ -1031,7 +1025,7 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength) } //Convert wxString in Unicode mode to a multi-byte string -const wxCharBuffer wxString::mb_str(wxMBConv& conv) const +const wxCharBuffer wxString::mb_str(const wxMBConv& conv) const { return conv.cWC2MB(c_str(), length() + 1 /* size, not length */, NULL); } @@ -1041,20 +1035,14 @@ const wxCharBuffer wxString::mb_str(wxMBConv& conv) const #if wxUSE_WCHAR_T // from wide string -wxString::wxString(const wchar_t *pwz, wxMBConv& conv, size_t nLength) +wxString::wxString(const wchar_t *pwz, const wxMBConv& conv, size_t nLength) { // anything to do? if ( pwz && nLength != 0 ) { if ( nLength == npos ) { - nLength = (size_t)-1; - } - else if ( nLength == length() ) - { - // this is important to avoid copying the string in cMB2WC: we're - // already NUL-terminated so we can pass this NUL with the data - nLength++; + nLength = wxNO_LEN; } size_t nLenMB; @@ -1067,7 +1055,7 @@ wxString::wxString(const wchar_t *pwz, wxMBConv& conv, size_t nLength) //Converts this string to a wide character string if unicode //mode is not enabled and wxUSE_WCHAR_T is enabled -const wxWCharBuffer wxString::wc_str(wxMBConv& conv) const +const wxWCharBuffer wxString::wc_str(const wxMBConv& conv) const { return conv.cMB2WC(c_str(), length() + 1 /* size, not length */, NULL); }