summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorstanton <stanton>1998-12-08 23:28:52 (GMT)
committerstanton <stanton>1998-12-08 23:28:52 (GMT)
commit46dea81b6f6888ccc9b9cc31d37a0b8aab93b8e6 (patch)
treef23e30363124130ea524635bf6178350480ac9ed /win
parentdd3f1a122804455aae3f6ebd176e4a201395d753 (diff)
downloadtk-46dea81b6f6888ccc9b9cc31d37a0b8aab93b8e6.zip
tk-46dea81b6f6888ccc9b9cc31d37a0b8aab93b8e6.tar.gz
tk-46dea81b6f6888ccc9b9cc31d37a0b8aab93b8e6.tar.bz2
* win/tkWinClipboard.c (TkSelGetSelection, TkWinClipboardRender):
Changed to handle multibyte characters properly. [Bug: 935]
Diffstat (limited to 'win')
-rw-r--r--win/tkWinClipboard.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index 87a4d34..c7e7cf5 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinClipboard.c,v 1.1.4.2 1998/09/30 02:19:29 stanton Exp $
+ * RCS: @(#) $Id: tkWinClipboard.c,v 1.1.4.3 1998/12/08 23:28:52 stanton Exp $
*/
#include "tkWinInt.h"
@@ -50,6 +50,7 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
ClientData clientData; /* Arbitrary value to pass to proc. */
{
char *data, *buffer, *destPtr;
+ Tcl_DString ds;
HGLOBAL handle;
int result, length;
@@ -72,8 +73,10 @@ TkSelGetSelection(interp, tkwin, selection, target, proc, clientData)
*destPtr = '\0';
GlobalUnlock(handle);
CloseClipboard();
- result = (*proc)(clientData, interp, buffer);
+ Tcl_ExternalToUtfDString(NULL, buffer, -1, &ds);
ckfree(buffer);
+ result = (*proc)(clientData, interp, Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
return result;
}
CloseClipboard();
@@ -162,8 +165,9 @@ TkWinClipboardRender(dispPtr, format)
TkClipboardTarget *targetPtr;
TkClipboardBuffer *cbPtr;
HGLOBAL handle;
- char *buffer, *p, *endPtr;
+ char *buffer, *p, *rawText, *endPtr;
int length;
+ Tcl_DString ds;
for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
targetPtr = targetPtr->nextPtr) {
@@ -183,11 +187,7 @@ TkWinClipboardRender(dispPtr, format)
}
}
}
- handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, length+1);
- if (!handle) {
- return;
- }
- buffer = GlobalLock(handle);
+ buffer = rawText = ckalloc(length + 1);
if (targetPtr != NULL) {
for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
cbPtr = cbPtr->nextPtr) {
@@ -201,7 +201,18 @@ TkWinClipboardRender(dispPtr, format)
}
}
*buffer = '\0';
+ Tcl_UtfToExternalDString(NULL, rawText, -1, &ds);
+ ckfree(rawText);
+ handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
+ Tcl_DStringLength(&ds)+1);
+ if (!handle) {
+ Tcl_DStringFree(&ds);
+ return;
+ }
+ buffer = GlobalLock(handle);
+ memcpy(buffer, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds) + 1);
GlobalUnlock(handle);
+ Tcl_DStringFree(&ds);
SetClipboardData(CF_TEXT, handle);
return;
}