]> git.saurik.com Git - wxWidgets.git/commitdiff
Use wxString methods for UTF-8 conversions in wxX11 code.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 27 Sep 2010 12:48:21 +0000 (12:48 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 27 Sep 2010 12:48:21 +0000 (12:48 +0000)
Use wxString::utf8_str() and FromUTF8() to convert to and from UTF-8. This is
more efficient than using wxConvUTF8 as the code did before as it avoids the
conversion entirely when wxString uses UTF-8 internally (as it does by default
in wxX11) and also has the advantage of compiling in STL build unlike the old
code.

Closes #12518.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65657 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/unix/fontutil.cpp
src/x11/dcclient.cpp

index a9fac62420d00cfe45df2c3fc67531f931ba1a79..39554c0fff1cdd2440ea84c5f8dafcf2066fbce6 100644 (file)
@@ -53,8 +53,8 @@
     #include "wx/x11/private.h"
     #include "wx/gtk/private/string.h"
 
     #include "wx/x11/private.h"
     #include "wx/gtk/private/string.h"
 
-    #define wxPANGO_CONV(s) (wxConvUTF8.cWX2MB((s)))
-    #define wxPANGO_CONV_BACK(s) (wxConvUTF8.cMB2WX((s)))
+    #define wxPANGO_CONV(s) s.utf8_str()
+    #define wxPANGO_CONV_BACK(s) wxString::FromUTF8Unchecked(s)
 #endif
 
 // ----------------------------------------------------------------------------
 #endif
 
 // ----------------------------------------------------------------------------
index 6ef0cb4f33a3304b72bce43dcf394dae911a7568..945b8d5e6cc8ef9a9966918a235a3a0dc46908be 100644 (file)
@@ -1570,7 +1570,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
     PangoLayout *layout = pango_layout_new(m_context);
     pango_layout_set_font_description(layout, m_fontdesc);
 
     PangoLayout *layout = pango_layout_new(m_context);
     pango_layout_set_font_description(layout, m_fontdesc);
 
-    const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
+    const wxScopedCharBuffer data(text.utf8_str());
     pango_layout_set_text(layout, data, data.length());
 
     // Measure layout.
     pango_layout_set_text(layout, data, data.length());
 
     // Measure layout.
@@ -1675,7 +1675,7 @@ void wxWindowDCImpl::DoGetTextExtent( const wxString &string, wxCoord *width, wx
     else
         pango_layout_set_font_description(layout, m_fontdesc);
 
     else
         pango_layout_set_font_description(layout, m_fontdesc);
 
-    const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
+    const wxScopedCharBuffer data(string.utf8_str());
     pango_layout_set_text(layout, data, data.length());
 
     // Measure text.
     pango_layout_set_text(layout, data, data.length());
 
     // Measure text.