I am trying to clean a string in C++. I would like to clean it for all non-alphabetical characters, and leave all kinds english AND non-english letters untouched. One of my test-codes looks like this
int main()
{
string test = "Danish letters: Æ Ø Å !!!!!!??||~";
cout << "Test = " << test << endl;
for(int l = 0;l<test.size();l++)
{
if(!isalpha(test.at(l)) && test.at(l) != ' ')
{
test.replace(l,1," nope");
}
}
cout << "Test = " << test << endl;
return 0;
}
Which gives me the output:
Test = Danish letters: Æ Ø Å !!!!!!??||~
Test = Danish letters nope nope nope nope nope nope nope nope nope nope nope nope nope nope nope nope nope nope"
So my question is, how do I remove the "!!!!!!??||~" and not the "Æ Ø Å"?
I've also tried tests like
test.at(l)!='Å'
but my I can't compile, if I declare 'Å' as a char.
I've read about unicode and utf8, but I don't really understand it.
Please help me out :)