Skip to content

Instantly share code, notes, and snippets.

@comuttun
Created November 4, 2012 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save comuttun/4014064 to your computer and use it in GitHub Desktop.
Save comuttun/4014064 to your computer and use it in GitHub Desktop.
Tera Term Copying to Clipboard Problem Fix
Index: trunk/teraterm/teraterm/clipboar.c
===================================================================
--- trunk/teraterm/teraterm/clipboar.c (revision 5057)
+++ trunk/teraterm/teraterm/clipboar.c (working copy)
@@ -67,6 +67,10 @@
void CBClose()
{
BOOL Empty;
+ HGLOBAL CBCopyWideHandle = NULL;
+ LPWSTR CBCopyWidePtr = NULL;
+ int WideCharLength;
+
if (CBCopyHandle==NULL) {
return;
}
@@ -76,6 +80,14 @@
Empty = (CBCopyPtr[0]==0);
}
+ WideCharLength = MultiByteToWideChar(CP_ACP, 0, CBCopyPtr, -1, NULL, 0);
+ CBCopyWideHandle = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR) * WideCharLength);
+ if (CBCopyWideHandle) {
+ CBCopyWidePtr = (LPWSTR)GlobalLock(CBCopyWideHandle);
+ MultiByteToWideChar(CP_ACP, 0, CBCopyPtr, -1, CBCopyWidePtr, WideCharLength);
+ GlobalUnlock(CBCopyWideHandle);
+ }
+
GlobalUnlock(CBCopyHandle);
CBCopyPtr = NULL;
@@ -83,10 +95,17 @@
EmptyClipboard();
if (! Empty) {
SetClipboardData(CF_TEXT, CBCopyHandle);
+ if (CBCopyWidePtr) {
+ SetClipboardData(CF_UNICODETEXT, CBCopyWideHandle);
+ }
}
CloseClipboard();
}
CBCopyHandle = NULL;
+
+ if (CBCopyWideHandle) {
+ GlobalFree(CBCopyWideHandle);
+ }
}
void CBStartPaste(HWND HWin, BOOL AddCR, BOOL Bracketed,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment