3 ms·
A character isn't just something that produces a picture, and advances the printing position to the right. Yes, a byte index will work if we have a multi-byte
by kazinator 4y ago
A character isn't just something that produces a picture, and advances the printing position to the right.
Yes, a byte index will work if we have a multi-byte string such as UTF-8; and a code point index would be inconvenient since displacement calculations on it are meaningless.
If we are talking about a string as an array of code points (like a wchar_t * string on sane platforms where a wchar_t can hold any code point) then we use code point indexing. C has wmemcpy, wmalloc, wstrlen, ...