I have a string that contains unicode characters (I don't know if I am using the correct nomenclature). I can look character by character, but I can't compare directly to it:
What is the correct way to look for the presence of a wide character?
Here it is MWE, I get an error when trying to compare the character with for example, "α".
#include<iostream>
int main(){
std::string s = " α a ";
std::cout << "s = " << s << std::endl;
for(std::string::iterator c = s.begin(); c != s.end(); ++c){
if(*c == 'a') std::cout << "letter a" << std::endl; // ok
if(*c == 'α') std::cout << "greek letter alpha" << std::endl; // error: character too large
std::cout << *c << std::endl;
}
return 0;
}
I am using clang 3.5 in Linux.
What I want to do is to (copy) replace a character by a word. I could use regular expressions but that seems to be an overkill.