forked from Mirrorlandia_minetest/irrlicht
Make clipboard UTF-8 on Windows too
This commit is contained in:
parent
9c4b6f25ab
commit
34f1f8d089
@ -70,16 +70,20 @@ void COSOperator::copyToClipboard(const c8 *text) const
|
|||||||
|
|
||||||
EmptyClipboard();
|
EmptyClipboard();
|
||||||
|
|
||||||
|
core::stringw tempbuffer;
|
||||||
|
core::multibyteToWString(tempbuffer, text);
|
||||||
|
const u32 size = (tempbuffer.size() + 1) * sizeof(wchar_t);
|
||||||
|
|
||||||
HGLOBAL clipbuffer;
|
HGLOBAL clipbuffer;
|
||||||
char * buffer;
|
void * buffer;
|
||||||
|
|
||||||
clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text)+1);
|
clipbuffer = GlobalAlloc(GMEM_MOVEABLE, size);
|
||||||
buffer = (char*)GlobalLock(clipbuffer);
|
buffer = GlobalLock(clipbuffer);
|
||||||
|
|
||||||
strcpy(buffer, text);
|
memcpy(buffer, tempbuffer.c_str(), size);
|
||||||
|
|
||||||
GlobalUnlock(clipbuffer);
|
GlobalUnlock(clipbuffer);
|
||||||
SetClipboardData(CF_TEXT, clipbuffer);
|
SetClipboardData(CF_UNICODETEXT, clipbuffer);
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
|
|
||||||
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
||||||
@ -113,13 +117,17 @@ const c8* COSOperator::getTextFromClipboard() const
|
|||||||
if (!OpenClipboard(NULL))
|
if (!OpenClipboard(NULL))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char * buffer = 0;
|
wchar_t * buffer = 0;
|
||||||
|
|
||||||
|
HANDLE hData = GetClipboardData( CF_UNICODETEXT );
|
||||||
|
buffer = (wchar_t*) GlobalLock( hData );
|
||||||
|
|
||||||
|
core::wStringToMultibyte(ClipboardBuf, buffer);
|
||||||
|
|
||||||
HANDLE hData = GetClipboardData( CF_TEXT );
|
|
||||||
buffer = (char*)GlobalLock( hData );
|
|
||||||
GlobalUnlock( hData );
|
GlobalUnlock( hData );
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
return buffer;
|
|
||||||
|
return ClipboardBuf.c_str();
|
||||||
|
|
||||||
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
||||||
NSString* str = nil;
|
NSString* str = nil;
|
||||||
|
@ -48,6 +48,10 @@ private:
|
|||||||
CIrrDeviceLinux * IrrDeviceLinux;
|
CIrrDeviceLinux * IrrDeviceLinux;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _IRR_WINDOWS_API_
|
||||||
|
mutable core::stringc ClipboardBuf;
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user