ios - CFStringCompare and case insensitive sorting -


our goal write case insensitive collation sqlite database. did multiple platforms, ios seems have consistent problems (occasionally) manifest in corrupted db indexes. after long experiments concluded culprit cfstringcompare() function, violates theoretical rules.

acc. theory comparison function must reflexive, symmtric , transitive.

what did generate random strings , test whether cfstringcompare() fulfills above properties.

here sample problem: cfstringcompare flags nscaseinsensitivesearch|nsdiacriticinsensitivesearch yielded:

"Я7;1fc9" > "sДa`\"0l" "sДa`\"0l" > "Я7;1fc9" 

in other words a>b @ same time when b>a!

we tested more flag combinations:

  • kcfcomparenonliteral showed similar problems
  • kcfcomparelocalized prove worst option (most problems)

does know safe way realize case insensitive comparison under ios?

ok, no reply, i'll try reply myself.

first of all, other people observed similar problems, example this link. note observed lot of problems german ß. selected example chance.

this should enough cfstringcompare has buggy implementation , cannot used sorting.

on other hand there icu library , declare full compliance uca (for example here), in turn should obey theoretical rules.

so answer be: cfstringcompare buggy, use icu.

(i hoped in answer because of huge size of icu library)


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -