Key number to Unicode string
Key number to Unicode string
- Subject: Key number to Unicode string
- From: email@hidden
- Date: Thu, 7 Jun 2007 19:48:20 +0400
Hello,
I write application a-la standard osx Keyboard Viewer. I need convert
key code to corresponding unicode char (using current input language).
KeyTranslate/UCKeyTranslate working fine only with English/French
layouts, but with Russian layout it returns english chars!
What the way to retrieve right symbols?
Here is code:
unichar KeyCodeToUnicode(UInt16 virtualKeyCode )
{
unsigned long state;
SInt16 currentKeyScript;
SInt16 lastKeyLayoutID;
unichar str[10];
UniCharCount actualLength;
UInt32 deadKeyState = 0;
char restype[] = "uchr";
ResType* rt = (ResType*)restype;
currentKeyScript = GetScriptManagerVariable(smKeyScript);
lastKeyLayoutID = GetScriptVariable(currentKeyScript, smScriptKeys);
deadKeyState = 0;
Handle hh = GetResource(*rt, lastKeyLayoutID);
if( hh )
{
UCKeyTranslate (
(const UCKeyboardLayout *)*hh,
virtualKeyCode,
kUCKeyActionDown,
0,
LMGetKbdType(),
0, // OptionBits keyTranslateOptions,
&deadKeyState,
sizeof(str)/sizeof(unichar),
&actualLength,
str
);
}
return str[0];
}
Thanks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden