The reason is that in Julia strings are UTF-8 encoded and you can index into them using byte count or character count. Some functions use the first approach and some the second. This is explained here in the Julia manual and additionally here in my blog. If some of the explanations are not clear please comment and I can expand on them.
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Unexpected index of Unicode subscript `char` in `string`? | 8 | 930 | June 25, 2021 | |
| Substring function? | 42 | 4332 | July 18, 2022 | |
| Performance of length(::String) | 24 | 4088 | July 28, 2018 | |
| String indices : byte indexing feels wrong | 18 | 1592 | December 5, 2023 | |
| How do I find the number of bytes for a character? | 3 | 245 | December 24, 2024 |