From: Robin Dunn Date: Tue, 22 Jul 2003 01:00:16 +0000 (+0000) Subject: Patch #775355 Unicode fix for STC X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/d99859e492c91806d2415def24fd91b3703b6d1b Patch #775355 Unicode fix for STC git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/contrib/include/wx/stc/stc.h b/contrib/include/wx/stc/stc.h index 2f54e83f76..a2060dbf88 100644 --- a/contrib/include/wx/stc/stc.h +++ b/contrib/include/wx/stc/stc.h @@ -2478,13 +2478,14 @@ inline wxString stc2wx(const char* str) { #endif } -inline wxString stc2wx(const char* str, size_t len) { #if wxUSE_UNICODE - return wxString(str, wxConvUTF8, len); +wxString stc2wx(const char* str, size_t len); #else +inline wxString stc2wx(const char* str, size_t len) { return wxString(str, len); -#endif } +#endif + #if wxUSE_UNICODE inline const wxWX2MBbuf wx2stc(const wxString& str) { diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index eb21c76bb2..98eba98548 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -481,7 +481,7 @@ void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positio // so figure it out and fix it! i = 0; size_t ui = 0; - while (i < len) { + while ((int)i < len) { unsigned char uch = (unsigned char)s[i]; positions[i++] = tpos[ui]; if (uch >= 0x80) { @@ -1223,6 +1223,22 @@ double ElapsedTime::Duration(bool reset) { //---------------------------------------------------------------------- +#if wxUSE_UNICODE +wxString stc2wx(const char* str, size_t len) +{ + char *buffer=new char[len+1]; + strncpy(buffer, str, len); + buffer[len]=0; + + wxString cstr(buffer, wxConvUTF8); + + delete[] buffer; + return cstr; +} +#endif + + + diff --git a/contrib/src/stc/stc.h.in b/contrib/src/stc/stc.h.in index 70addc7abb..e1c17422a1 100644 --- a/contrib/src/stc/stc.h.in +++ b/contrib/src/stc/stc.h.in @@ -463,13 +463,14 @@ inline wxString stc2wx(const char* str) { #endif } -inline wxString stc2wx(const char* str, size_t len) { #if wxUSE_UNICODE - return wxString(str, wxConvUTF8, len); +wxString stc2wx(const char* str, size_t len); #else +inline wxString stc2wx(const char* str, size_t len) { return wxString(str, len); -#endif } +#endif + #if wxUSE_UNICODE inline const wxWX2MBbuf wx2stc(const wxString& str) { diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 2f54e83f76..a2060dbf88 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -2478,13 +2478,14 @@ inline wxString stc2wx(const char* str) { #endif } -inline wxString stc2wx(const char* str, size_t len) { #if wxUSE_UNICODE - return wxString(str, wxConvUTF8, len); +wxString stc2wx(const char* str, size_t len); #else +inline wxString stc2wx(const char* str, size_t len) { return wxString(str, len); -#endif } +#endif + #if wxUSE_UNICODE inline const wxWX2MBbuf wx2stc(const wxString& str) { diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index eb21c76bb2..98eba98548 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -481,7 +481,7 @@ void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positio // so figure it out and fix it! i = 0; size_t ui = 0; - while (i < len) { + while ((int)i < len) { unsigned char uch = (unsigned char)s[i]; positions[i++] = tpos[ui]; if (uch >= 0x80) { @@ -1223,6 +1223,22 @@ double ElapsedTime::Duration(bool reset) { //---------------------------------------------------------------------- +#if wxUSE_UNICODE +wxString stc2wx(const char* str, size_t len) +{ + char *buffer=new char[len+1]; + strncpy(buffer, str, len); + buffer[len]=0; + + wxString cstr(buffer, wxConvUTF8); + + delete[] buffer; + return cstr; +} +#endif + + + diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 70addc7abb..e1c17422a1 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -463,13 +463,14 @@ inline wxString stc2wx(const char* str) { #endif } -inline wxString stc2wx(const char* str, size_t len) { #if wxUSE_UNICODE - return wxString(str, wxConvUTF8, len); +wxString stc2wx(const char* str, size_t len); #else +inline wxString stc2wx(const char* str, size_t len) { return wxString(str, len); -#endif } +#endif + #if wxUSE_UNICODE inline const wxWX2MBbuf wx2stc(const wxString& str) {