Making normalized version of string in sqlite - polish character ł

database, objective-c, sqlite, string

Solution

I don't speak polish, so my answer may be terribly wrong, but according to http://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt the characters "ł" and "Ł" are not combinations of an "ordinary" character with a diacritical mark.

The entry for "ą" in the Unicode Data file is

0105;LATIN SMALL LETTER A WITH OGONEK;Ll;0;L;0061 0328;;;;N;LATIN SMALL LETTER A OGONEK;;0104;;0104

and the sixth field "0061 0328" shows that "ą" can be decomposed into "a" and U+0328 (COMBINING OGONEK).

But the entries for "ł" and "Ł" are

0141;LATIN CAPITAL LETTER L WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER L SLASH;;;0142;
0142;LATIN SMALL LETTER L WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER L SLASH;;0141;;0141

where the sixth field is empty, so these characters do not have a decomposition.

Therefore I doubt that there will be any function that normalizes "ł" into "l", and you would have to do that using

[result replaceOccurrencesOfString:@"ł" withString:@"l" options:0 range:NSMakeRange(0, [result length])];

Problem

Apple delivers example of making additional column in database with normalized version of text stored in database: DerivedProperty There is function normalizeString which contains code: ``` NSMutableString *result = [NSMutableString stringWithString:unprocessedValue]; CFStringNormalize((CFMutableStringRef)result, kCFStringNormalizationFormD); CFStringFold((CFMutableStringRef)result, kCFCompareCaseInsensitive | kCFCompareDiacriticInsensitive | kCFCompareWidthInsensitive, NULL); ``` I've tested this method and there is example of conversion of text to normalized version: `ąĄćłŁÓŻźŃĘęĆ` -> `aacłłozzneec` all diacritic characters were changed properly except characters: `łŁ` Is there any other option to make proper normalization?

Original source