PDA

View Full Version : Convert to unicode text



SirJonas
26th October 2016, 12:42
Hi normally when i convert the data string i do this

QString::fromUtf16((ushort*)data);
But how i can convert to unicode??

ChrisW67
26th October 2016, 13:07
From what?

SirJonas
26th October 2016, 13:28
of the data of my program. I convert to string but in unicode i dont remember how¿?

Lesiok
26th October 2016, 14:33
Do you meanQString::utf16() or QString::toUtf8() ?

SirJonas
26th October 2016, 16:37
i'm trying to show some unicode key's for this i ask.
I tried using this.

int result = ToUnicodeEx(cKey->vkCode, cKey->scanCode, keyboard_state, buffer,4,0, keyboard_layout);
all time show me or 0 or 1 so i was thinking to use this.
std::vector keys(256, 0);
int sc = MapVirtualKey(vk, MAPVK_VK_TO_VSC);
return1 = ToUnicode(vk, sc, keys.data(), buffer, 1, 0);

But show me some errors. my question is impossible to use winapi with qt?

ChrisW67
26th October 2016, 20:23
Qt does not stop you using the Windows API.


int result = ToUnicodeEx(cKey->vkCode, cKey->scanCode, keyboard_state, buffer,4,0, keyboard_layout);
all time show me or 0 or 1 so i was thinking to use this.
Result equal 0 or 1 is normal. What is in buffer when result is 1?
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646322(v=vs.85).aspx

What does this have to do with your initial question?