I have the virtual key and scan code for a particular character (in this case 'つ') and I would like to convert it back to the Japanese character. How should I go about doing it? I've searched and tried the below code. However, it's not working... It only works for if the characters are ASCII.
FYI.
- I am only saving the VK/SC and not generating a keypress directly so I can't work with WM_CHAR.
- The 'Z' key on a Japanese keyboard generates 'つ'
CodePudding user response:
IME is involved in this case. ToUnicode
is working with usual keyboard layouts (that have SC/VK/CHAR tables inside their dlls).
AFAIK in Japanese case English keyboard layout is used with Japanese IME on top of it - thats why you cannot simply use ToUnicode
to produce Japansese chars.
On the other side - IME injects WM_CHAR
messages into your window's message queue after 'TranslateMessage' call. IMEs can be a quite complex. They can produce characters from different sources - keydown, voice, char etc.
Proper way is to process WM_CHAR
and do not try to do deal with IME APIs by yourself...