Given a string, I'm trying to determine which letter of the alphabet it belongs to. For example, "apple" goes into the "A" section. "Banana" goes into the "B" section. I'm using this to identify the section:
NSRange range = [string rangeOfString:letter
options:NSAnchoredSearch |
NSCaseInsensitiveSearch |
NSDiacriticInsensitiveSearch |
NSWidthInsensitiveSearch
range:NSMakeRange(0, string.length)
locale:locale];
Where string
is the string I'm trying to bucket and letter
is a letter of the alphabet. I do this in a loop for each letter of the alphabet.
It works great, except for words like "æquo", which should be bucketed into the letter "A", but aren't. What to do?
Edit The plot thickens. I'm looking at Korean now. The word "것" should be bucketed into the letter "ㄱ". There's got to be some way to do this other than maintaining a huge mapping table.