Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSv. Lockal <lockalsash@gmail.com>2012-01-16 19:00:28 +0400
committerSv. Lockal <lockalsash@gmail.com>2012-01-16 19:00:28 +0400
commitefc6be2002bfb250374fb0f43d1260e5c8c2b0ed (patch)
tree4ca5f1c6b22f8d13130fac56fd8cbbbb4b40d113 /intern/ghost
parent3b12a4b92b3115c0be4f194bb77edb9d4173e018 (diff)
patch [#29856] UTF-8 copy&paste for Win32 GHOST
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 4ae87da4efe..9cae2c27e65 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1240,26 +1240,25 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
GHOST_TUns8* GHOST_SystemWin32::getClipboard(bool selection) const
{
- char *buffer;
+ wchar_t *buffer;
char *temp_buff;
- if ( IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL) ) {
+ if ( IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL) ) {
size_t len = 0;
- HANDLE hData = GetClipboardData( CF_TEXT );
+ HANDLE hData = GetClipboardData( CF_UNICODETEXT );
if (hData == NULL) {
CloseClipboard();
return NULL;
}
- buffer = (char*)GlobalLock( hData );
+ buffer = (wchar_t*)GlobalLock( hData );
if (!buffer) {
CloseClipboard();
return NULL;
}
- len = strlen(buffer);
- temp_buff = (char*) malloc(len+1);
- strncpy(temp_buff, buffer, len);
- temp_buff[len] = '\0';
+ len = WideCharToMultiByte(CP_UTF8, 0, buffer, -1, NULL, 0, NULL, NULL);
+ temp_buff = (char*) malloc(len);
+ WideCharToMultiByte(CP_UTF8, 0, buffer, -1, temp_buff, len, NULL, NULL);
/* Buffer mustn't be accessed after CloseClipboard
it would like accessing free-d memory */
@@ -1278,18 +1277,20 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const
if (OpenClipboard(NULL)) {
HLOCAL clipbuffer;
- char *data;
+ wchar_t *data;
if (buffer) {
EmptyClipboard();
- clipbuffer = LocalAlloc(LMEM_FIXED,((strlen(buffer)+1)));
- data = (char*)GlobalLock(clipbuffer);
-
- strcpy(data, (char*)buffer);
- data[strlen(buffer)] = '\0';
+ int wlen = MultiByteToWideChar(CP_UTF8, 0, buffer, -1, NULL, 0);
+
+ clipbuffer = LocalAlloc(LMEM_FIXED, wlen * sizeof(wchar_t));
+ data = (wchar_t*)GlobalLock(clipbuffer);
+
+ MultiByteToWideChar(CP_UTF8, 0, buffer, -1, data, wlen);
+
LocalUnlock(clipbuffer);
- SetClipboardData(CF_TEXT,clipbuffer);
+ SetClipboardData(CF_UNICODETEXT,clipbuffer);
}
CloseClipboard();
} else {