+#endif // wxUSE_UNICODE_WCHAR/wxUSE_UNICODE_UTF8
+
+#elif defined(wxNEEDS_UTF16_FOR_TEXT_DATAOBJ)
+
+namespace
+{
+
+inline wxMBConv& GetConv(const wxDataFormat& format)
+{
+ static wxMBConvUTF16 s_UTF16Converter;
+
+ return format == wxDF_UNICODETEXT ? static_cast<wxMBConv&>(s_UTF16Converter)
+ : static_cast<wxMBConv&>(wxConvLocal);
+}
+
+} // anonymous namespace
+
+size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const
+{
+ return GetConv(format).WC2MB(NULL, GetText().wc_str(), 0);
+}
+
+bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const
+{
+ if ( buf == NULL )
+ return false;
+
+ wxCharBuffer buffer(GetConv(format).cWX2MB(GetText().c_str()));
+
+ memcpy(buf, buffer.data(), buffer.length());
+
+ return true;
+}
+
+bool wxTextDataObject::SetData(const wxDataFormat& format,
+ size_t WXUNUSED(len),
+ const void *buf)
+{
+ if ( buf == NULL )
+ return false;
+
+ SetText(GetConv(format).cMB2WX(static_cast<const char*>(buf)));
+
+ return true;
+}
+
+#else // !wxNEEDS_UTF{8,16}_FOR_TEXT_DATAOBJ
+
+size_t wxTextDataObject::GetDataSize() const
+{
+ return GetTextLength() * sizeof(wxChar);
+}
+
+bool wxTextDataObject::GetDataHere(void *buf) const
+{
+ // NOTE: use wxTmemcpy() instead of wxStrncpy() to allow
+ // retrieval of strings with embedded NULLs
+ wxTmemcpy( (wxChar*)buf, GetText().c_str(), GetTextLength() );
+
+ return true;
+}
+
+bool wxTextDataObject::SetData(size_t len, const void *buf)
+{
+ SetText( wxString((const wxChar*)buf, len/sizeof(wxChar)) );
+
+ return true;
+}
+
+#endif // different wxTextDataObject implementations