Dealing with special letter characters

Hi everyone,
I have a string that contains a special characters

string temp = "B°b";

When i count the size i have 4 instead of 3 and if i try to print every character i get code (like \233 \033, not this, similar).

for (int i = 0; i <  temp.size() ; i++){
        cout <<  temp[i] << endl;

Anybody knows how to deal with it?

It’s not super important, i deleted this type of string for now, but i think it could be useful in the future to know what to do in this cases.

those characters are not part of the ascii table. a string is just an array of chars (1 byte). the ascii standard maps each of these chars (which is just a number ) to a specific character. But it is only capable of mapping 255 different characters, not enough for all the characters on all languages. Thus the UTF-8 standard came in.
Then, other “special” characters were added and use that notation you mention, where characters can be enconded using multiple bytes. In the case you point out, the middle character is using 2 bytes.
OpenFrameworks provides some useful tools for dealing with UTF8 strings

use ofUTF8Iterator to go through the string in a for loop

1 Like

Very helpful.
Thank you!