fix paste of text with accents in win32

This commit is contained in:
Eduardo Bart 2012-01-19 16:50:56 -02:00
parent 9b8043cf31
commit 490eae7814
2 changed files with 14 additions and 7 deletions

View File

@ -25,6 +25,7 @@
#include <framework/application.h>
#include <framework/thirdparty/apngloader.h>
#include <framework/core/resourcemanager.h>
#include <framework/util/utf8.h>
WIN32Window::WIN32Window()
{
@ -665,7 +666,7 @@ std::string WIN32Window::getClipboardText()
if(hglb) {
LPTSTR lptstr = (LPTSTR)GlobalLock(hglb);
if(lptstr) {
text = lptstr;
text = Fw::utf8StringToLatin1((uchar*)lptstr);
GlobalUnlock(hglb);
}
}

View File

@ -27,16 +27,22 @@
char Fw::utf8CharToLatin1(uchar *utf8, int *read)
{
if(utf8[0] == 0xc3) {
char c = '?';
uchar opt1 = utf8[0];
if(opt1 == 0xc3) {
*read = 2;
return (char)(64 + utf8[1]);
} else if(utf8[0] == 0xc2) {
uchar opt2 = utf8[1];
c = 64 + opt2;
} else if(opt1 == 0xc2) {
*read = 2;
return utf8[1];
} else {
uchar opt2 = utf8[1];
if(opt2 > 0xa1 && opt2 < 0xbb)
c = opt2;
} else if(opt1 < 0xc2) {
*read = 1;
return utf8[0];
c = opt1;
}
return c;
}
std::string Fw::utf8StringToLatin1(uchar *utf8) {