]> git.saurik.com Git - wxWidgets.git/commitdiff
correcting unicode data conversion
authorStefan Csomor <csomor@advancedconcepts.ch>
Sat, 28 Aug 2004 08:45:42 +0000 (08:45 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sat, 28 Aug 2004 08:45:42 +0000 (08:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/dobjcmn.cpp

index b16c8e219fcfa5248dc14f80a42d3081bd726e05..0957f4b47ffdb19fe2d8238ba8d79604998982c5 100644 (file)
@@ -290,8 +290,7 @@ size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const
     {
         // host native is UTF16
            wxMBConvUTF16BE converter ;
-        wxCharBuffer buffer = converter.cWX2MB( GetText().c_str() );
-        return strlen( (const char*) buffer ) + 1;
+        return converter.WC2MB( NULL , GetText().c_str() , 0 ) + 2; // add space for trailing unichar 0
     }
     else  // == wxDF_TEXT
     {
@@ -306,8 +305,9 @@ bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const
     {
         // host native is UTF16
            wxMBConvUTF16BE converter ;
+           size_t len = converter.WC2MB( NULL , GetText().c_str() , 0 ) ;
         wxCharBuffer buffer = converter.cWX2MB( GetText().c_str() );
-        strcpy( (char*) buf, (const char*) buffer );
+        memcpy( (char*) buf, (const char*) buffer , len + 2); // trailing unichar 0
     }
     else
     {