mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
UTF16 (Swedish grapheme cluster) issues #293
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rivera-ernesto on GitHub (Nov 1, 2019).
I have described this issue here https://stackoverflow.com/q/58660170/1049134
Basically I store an
identifierstring with UTF16 Swedish characters:"/EXTERNAL/Gemensam RUN/FileCloud Test/Test folder åäö/Test with Swedish characters - åäö.xlsx"Which then don't match a fetch:
CoreStore.fetchOne(From<Record>().where(\.identifier == identifier)) // Fails@JohnEstropia commented on GitHub (Nov 5, 2019):
What type is
identifier?@JohnEstropia commented on GitHub (Nov 5, 2019):
Also, what happens if you use
NSPredicateinstead?@rivera-ernesto commented on GitHub (Nov 6, 2019):
identifieris a Swift string. Found the problem and updated the StackOverflow issue.In short I had two
identifierinstances with Swedish characters that are written with different grapheme clusters, so two binary different but both valid representations of the same String.They are considered equal by Swift but for Core Data (and I guess because of SQLite under it) they are not considered equal, so they don't match the predicate.
It's not a problem of encoding, as both representations are in the same encoding, is a problem of grapheme clusters being valid in more than one way, and no way to "normalize" them that I could find.
Again refer to https://stackoverflow.com/q/58660170/1049134 if you are interested to know more.
@JohnEstropia commented on GitHub (Nov 8, 2019):
@rivera-ernesto I see. If that's the case I'm not sure this is something that should be "fixed" at the library level. Here are some common practices for such cases: