Cant work with characters like á à ã ă â é è ê

  ascii, c++, extended-ascii, string, text

My code is supposed to clear any character that isnt a-z or A-Z.For these á à ã ă â é è ê characters if i can make it work,i ll make them change from á to a and è to e etc.

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int counter=0;
    string* word = new string[1];
    string b ="áhelloá";//nothing

    word[0] = "áapple_.Dogá.";//doesnt work
    //word[0] = "apple_.Dog.";//if there is no characters like á it works
    cout<<endl<<word[0].length()<<endl;

    for (int i = 0; i < word[0].length(); ++i)
    {
        if(word[0][i] >= 'A' && word[0][i] <='Z' || word[0][i] >= 'a' && word[0][i] <='z')
        {
            cout<<"Current: "<<word[0][i]<<endl;//shows what characters passed if
        }
        else
        {
            cout<<"Erased: "<<word[0][i]<<endl;//shows what was erased
            word[0].erase(i,1);//deletes char
            i--;
        }
    }

    cout<<endl<<word[0];//prints final word,after erase

    return 0;
}

If i run my code with for example á in Clion it doesnt do anything and returns 0.I tested the same on Replit and it somewhat works as intended,i think.Is there a problem with my Clion?What am i doing wrong?

Source: Windows Questions C++

LEAVE A COMMENT