Re: Sending keyboard events with unicode strings causes Pages/Keynote/Numbers to hang
Re: Sending keyboard events with unicode strings causes Pages/Keynote/Numbers to hang
- Subject: Re: Sending keyboard events with unicode strings causes Pages/Keynote/Numbers to hang
- From: Ken Thomases <email@hidden>
- Date: Mon, 13 Aug 2012 09:38:44 -0500
On Aug 11, 2012, at 3:39 PM, Huy Phan wrote:
> Every time I send keyboard events with unicode strings contain 2-byte unicode characters, …
> CGEventKeyboardSetUnicodeString(keyEventDown, 1, unicodeString);
> CGEventKeyboardSetUnicodeString(keyEventUp, 1, unicodeString);
> Pages doesn't hang if unicodeString contains only 1-byte unicode character.
Above you mention 2-byte unicode characters and here you mention 1-byte unicode characters. What precisely do you mean? A "UniChar" is inherently 2-bytes. So the first mention (2-byte) seems redundant and the second is just wrong.
Also, note that there are some Unicode characters which can't be represented by a single UniChar. Apple's UniChar and unichar types, the basis of CFString and NSString, are actually UTF-16 "code units", not really Unicode characters or "code points". These terms have precise definitions in the Unicode standard, with which Apple's terminology does not conform. Anyway, some Unicode characters will require two UTF-16 code units (a.k.a. UniChar values) to represent completely. These are surrogate pairs. Is there any chance you're putting an incomplete Unicode character, an unpaired surrogate, in your event?
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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