- SetData(wxDataFormat(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT),
- url.Length()+1, url.c_str());
+ wxCharBuffer urlMB(url.mb_str());
+ if ( urlMB )
+ {
+ const size_t len = strlen(urlMB);
+
+#if !wxUSE_UNICODE
+ // wxTextDataObject takes the number of characters in the string, not
+ // the size of the buffer (which would be len+1)
+ SetData(wxDF_TEXT, len, urlMB);
+#endif // !wxUSE_UNICODE
+
+ // however CFSTR_SHELLURLDataObject doesn't append NUL automatically
+ // but we probably still want to have it on the clipboard (just to be
+ // safe), so do append it
+ SetData(wxDataFormat(CFSTR_SHELLURL), len + 1, urlMB);
+ }