Unexpected behaviour using remove on char
nise at nise.com
Sun Oct 25 19:29:41 UTC 2020
I have a part in my code that use remove
What I discovered is that remove doesn't really remove size
number of bytes but also removed entire multibyte characters and
consider that one step. The result was of course that I got out
of bounds exceptions as it went past the end.
When I changed char to ubyte my code started to work
According to the documentation a char is an "unsigned 8 bit
(UTF-8 code unit)" so you really believe you are working on
bytes. I presume that under the hood there are range iterators at
work and those work multibyte characters. However you can iterate
over one byte characters as well as an option and you don't know
what happens underneath.
I'm a bit confused, when should I expect that the primitives work
with single versus multibyte chars in array operations?
More information about the Digitalmars-d-learn