c++ - How can I parse the Euro symbol from a string? -


i'm trying parse string character per character can load image depending on every letter. if text "hello" print 5 images same letters made in photoshop. works fine until want parse € symbol.

std::string al = "test €";  std::string letter=""; (int i=0; i< al.length();++i) {     if (al[i]=='.') letter ="dot";     else if (al[i]==',') letter ="coma";     else if (al[i]==' ') letter ="space";     //else if (al[i]=='€') letter ="euro";     else letter=al[i]; } 

this works fine: letter adquire values:"t","e","s","t","space" if uncomment else if (al[i]=='€') letter ="euro"; , try build it, receive red mesage error says:

warning: multi-character character constant

so thing need know if al[i] € symbol able assing "euro" letter (then code able work it)

i've search on google , found link says "\u20ac" c++ code € , suppose symbol needs more byte maybe, still can't find how deal , able parse in code. idea of how it?

thank much.

note: don't know c++ version used (dunno can check it) know not c++11

the first issue should mindful of using unicode characters in source code. compilers required support specific character set , not compilers may code. suggest read this answer more detailed explanation.

second problem character large represented in character literal. need explicitly tell compiler use wide character literal instead.

l'\x20ac`   // notice preceeding l 

the third problem rest of code still uses narrow character strings. change std::string std::wstring.


Comments