News for hackers. Stuff that matters.
Re:Counting the number of matching characters in two ASCII s... by rocqua on Friday May 21, 2021 @01:16PM (#27236929)
For UTF-8 I believe the question is ill-posed. The "position" of a "character" in unicode is very hard to determine and depends largely on what you take to be a character.
Re:Counting the number of matching characters in two ASCII s... by bmn__ on Friday May 21, 2021 @03:05PM (#27238495)
Then UTF-8 should not be operated on directly. When reading from a file etc., first decode the input into an internal string format that has straight-forward linear access to each gc boundary.
Re:Counting the number of matching characters in two ASCII s... by eesmith on Friday May 21, 2021 @03:52PM (#27239075)
Even then, https://en.wikipedia.org/wiki/Unicode_equivalence . What does "matching character" mean given combining characters?
Re:Counting the number of matching characters in two ASCII s... by rocqua on Friday May 21, 2021 @04:38PM (#27239655)
Probably pick a canonical encoding and compare there.
Re:Counting the number of matching characters in two ASCII s... by ygra on Saturday May 22, 2021 @01:49AM (#27243891)
Yeah, that's what the normalization forms are for. But still, almost no question how to do things in Unicode can be answered in a single sentence without disregarding 99 % of the complexity.