Skip navigation.
 
mlRe: characterAtIndex: method and composite characters
FROM : Greg Titus
DATE : Wed Apr 04 17:12:25 2007

On Apr 4, 2007, at 8:05 AM, Ewan Delanoy wrote:
>  -when an NSString or
> NSAttributedString (let's call it s) appears on-screen as, say, "(a 
> with
> tilda)(other characters ...)" is
> it guaranteed that  [s characterAtIndex: 0] will be "a with tilda", 
> and
> not "a" (with "tilda" for a second
> character) ?
>
>  -If this is not the case, I need a more accurate version of
> "characterAtIndex:". Is this already
> built-in ?


You want the -precomposedStringWithCanonicalMapping, and -
decomposedStringWithCanonicalMapping methods. Depending upon what you 
mean by "more accurate" (one isn't really any more accurate than the 
other), you take your original string (which might be either way) and 
call the precomposed method to get a new string which is guaranteed 
to be in the "a with tilde" form, or the decomposed method to get a 
new string which is guaranteed to be in the "a with tilde for second 
character" form.

Hope this helps,
   - Greg