Re: characters in cocoa
Re: characters in cocoa
- Subject: Re: characters in cocoa
- From: "Lukhnos D. Liu" <email@hidden>
- Date: Fri, 7 Sep 2007 18:04:43 +0800
On Sep 7, 2007, at 5:17 PM, Hans van der Meer wrote:
This is a question about the treatment of characters in Cocoa.
Because my program will do a lot with individual characters, both as
basic type as well as encapsulated in objects, I am anxious to get
it right from the start. I feel I should refrain in Cocoa as much as
possible from working with plain C's char's, especially in the light
of the (unsigned char) - (signed char) dilemma. Is that correct?
My apps must work with CJK characters all the time. My experience is--
it's pretty ok to work with UTF-8 with char/char* and UTF-16 with
UniChar or just a plain unsigned short (any unsigned 16-bit word, that
is). I don't really see a need to abstract too much from that--and on
that same reason feel ok not to have [NSNumber numberWithUniChar:<a
unichar>]. +numberWithUnsignedShort suffices.
The thing is that NSString (as I know of, I might be ignorant on this)
doesn't work on codepoint level, and I always to have compute the
codepoint length (the real string length, not the one returned by -
length) and do the surrogate exercise on my own (I now have some stock
libraries for that though). An NSCharacter would only be useful if it
operates on the codepoint level.
So in short I really treat NSString like a UTF-16 vector, use UniChar/
unsigned short all the time, and do the character-level operation on
my own. But yeah, if Cocoa does have codepoint-level string
operations, so much the better...
d.
_______________________________________________
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