- if (format == wxDF_UNICODETEXT)
- {
- // host native is UTF16
- wxMBConvUTF16 converter ;
- size_t len = converter.WC2MB( NULL , GetText().c_str() , 0 ) ;
- wxCharBuffer buffer = converter.cWX2MB( GetText().c_str() );
- memcpy( (char*) buf, (const char*) buffer , len + 2); // trailing unichar 0
- }
- else
- {
- wxCharBuffer buffer = wxConvLibc.cWX2MB( GetText().c_str() );
- strcpy( (char*) buf, (const char*) buffer );
- }
+ wxCharBuffer buffer = GetConv(format).cWX2MB( GetText().c_str() );
+ if ( !buffer )
+ return false;
+
+ size_t len = GetConv(format).WC2MB( NULL , GetText().c_str() , 0 )
+ + ( format == wxDF_UNICODETEXT ? 2 : 1 ) ;
+
+ memcpy( (char*) buf, (const char*) buffer , len ); // trailing (uni)char 0