]> git.saurik.com Git - wxWidgets.git/commitdiff
added FromUTF8Unchecked() for ANSI build too
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 21 Jul 2008 02:26:11 +0000 (02:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 21 Jul 2008 02:26:11 +0000 (02:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54737 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/string.h

index 118232f1dbb2a4d7a4a9da6f996288d068a534b1..0a72bfe3206dacfb33d94b37044935577a9cfc1f 100644 (file)
@@ -1328,9 +1328,20 @@ public:
       { return wxString(wxMBConvUTF8().cMB2WC(utf8)); }
     static wxString FromUTF8(const char *utf8, size_t len)
     {
-      size_t wlen;
-      wxWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen));
-      return wxString(buf.data(), wlen);
+        size_t wlen;
+        wxWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen));
+        return wxString(buf.data(), wlen);
+    }
+    static wxString FromUTF8Unchecked(const char *utf8, size_t len = npos)
+    {
+        size_t wlen;
+        wxWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8,
+                                                len == npos ? wxNO_LEN : len,
+                                                &wlen));
+        wxASSERT_MSG( !utf8 || !*utf8 || wlen,
+                      "string must be valid UTF-8" );
+
+        return wxString(buf.data(), wlen);
     }
     const wxCharBuffer utf8_str() const
       { return wxMBConvUTF8().cWC2MB(wc_str()); }