# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1339836550 0 # Node ID eeec5ceec7a5c0fb2a3a3d32a4320253d1a84ace # Parent 87c215963fdc2c4243dec5878b8bde04b0347a4c Enable unicode cut and paste on Windows. diff -r 87c215963fdc -r eeec5ceec7a5 win/dw.c --- a/win/dw.c Sat Jun 16 06:24:08 2012 +0000 +++ b/win/dw.c Sat Jun 16 08:49:10 2012 +0000 @@ -11556,20 +11556,26 @@ char * API dw_clipboard_get_text(void) { HANDLE handle; - char *tmp, *ret = NULL; + char *ret = NULL; + TCHAR *tmp; +#ifdef UNICODE + int type = CF_UNICODETEXT; +#else + int type = CF_TEXT; +#endif if ( !OpenClipboard( NULL ) ) return ret; - if ( ( handle = GetClipboardData( CF_TEXT) ) == NULL ) + if ( ( handle = GetClipboardData(type) ) == NULL ) { CloseClipboard(); return ret; } - if ( (tmp = GlobalLock(handle)) && strlen(tmp) ) - { - ret = _strdup(tmp); + if ( (tmp = GlobalLock(handle)) && _tcslen(tmp) ) + { + ret = _strdup(WideToUTF8(tmp)); GlobalUnlock(handle); } CloseClipboard(); @@ -11585,6 +11591,20 @@ { HGLOBAL ptr1; LPTSTR ptr2; + TCHAR *buf; +#ifdef UNICODE + int type = CF_UNICODETEXT; + char *src = calloc(len + 1, 1); + + memcpy(src, str, len); + buf = UTF8toWide(src); + free(src); + len = _tcslen(buf); +#else + int type = CF_TEXT; + + buf = str; +#endif if ( !OpenClipboard( NULL ) ) return; @@ -11596,16 +11616,14 @@ ptr2 = GlobalLock( ptr1 ); - memcpy( (char *)ptr2, str, len + 1); + memcpy(ptr2, buf, (len + 1) * sizeof(TCHAR)); GlobalUnlock( ptr1 ); EmptyClipboard(); - SetClipboardData( CF_TEXT, ptr1 ); + SetClipboardData( type, ptr1 ); CloseClipboard(); GlobalFree( ptr1 ); - - return; } /*