I've been working with C++, and have used std
library; specially, the method string::substr
.
I have detected some errors in this method that I want to tell you.
- For a string
abcñ
, a call tosubstr(0, 4)
returnsabc?
. - For a string
abcç
, a call tosubstr(0, 4)
returnsabc?
. - For a string
abcñd
, a call tosubstr(0, 5)
returnsabcñ
. - For a string
abcçd
, a call tosubstr(0, 5)
returnsabcç
.
I have noticed with these tests, that strange characters (such as ñ
or ç
), take up a double size. But, shouldn't string::substr
keep this fact in mind, or work with different codifications? In the API, there is no method to work with different codifications.