This is probably not sufficient.  The string @"é" can be represented
by two characters, an 'e' and a combining accent.  It is unlikely to
be correct to insert a space between them.  This is unrelated to lower
level issues, like some unicode code points taking more than one 16
bit unichar to represent.

The method -[NSString rangeOfComposedCharacterSequenceAtIndex:] will
give you chunks of characters that should not be broken up by
operations such as adding a space.  You could use that.

The suggestion of modifying the kerning sounds better to me, though,
if it applies.

-Ken

On Tue, Mar 18, 2008 at 9:18 PM, stephen joseph butler
<[EMAIL PROTECTED]> wrote:
> On Tue, Mar 18, 2008 at 11:10 PM, stephen joseph butler <
>  [EMAIL PROTECTED]> wrote:
>
>  > Yes; there's not a good, easy way to do this. One implementation that at
>  > first seems correct is this:
>  >
>  > from = [NSMutableString string];
>  > for (int i = 0; i < [to length]; ++i)
>  >   [from appendFormat:@"%C ", [from characterAtIndex:i]];
>  >
>  > That is, until you realize that unichar is 16 bit, and some "characters"
>  > are encoded as two unichar's. Opps! A better implementation, relying on the
>  > fact that NSString is UTF16 (I don't think endianess would matter here),
>  > would do this:
>  >
>  > from = [NSMutableString string];
>  > for (int i = 0; i < [to length]; ++i) {
>  >   unichar c = [from characterAtIndex:i];
>  >
>  >   if ((c >= 0xD800) && (c <= 0xDBFF))
>  >     [from appendFormat:@"%C", c];
>  >   else
>  >     [from appendFormat:@"%C ", c];
>  > }
>  >
>
>  Wow. I am more tired that I thought. Please use the right variable instead
>  of my horribly confusing "from" and "to". I hope you get the point anyway :)
>
>
> _______________________________________________
>
>  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>  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:
>  http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>
>  This email sent to [EMAIL PROTECTED]
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to