I have a helper structure that helps working with string indices:
struct StringIndex {
let string: String
let index: String.Index
}
What's the best way to assert that the two arbitrary indices belong to "the same" string? I presume "a.string == b.string" is not the right check as two different strings might compare equal, e.g.:
U+00C5 (LATIN CAPITAL LETTER A WITH RING ABOVE) ==
U+0041 + U+030A (LATIN CAPITAL LETTER A + COMBINING RING ABOVE)
Would this check on utf8 representations be correct for the assert?
a.utf8CString == b.utf8CString
Note, in my code all indices are created with "string.startIndex", "string.index(after:)", etc. and I am not mixing and matching indices created via different views... (it would also be cool if I can assert that fact as well, if that's possible / necessary).