I have the following code:
cout << "String that includes a £ sign";
However, the £ sign is not being recognised by the compiler, and instead an accented u is being displayed. I'm able to insert one using the following method:
cout << "String that includes a " << char(156) << " sign";
where 156 is the ASCII code of the £ sign. Is there a way I can include this ASCII code in the string itself without having to separate it out like this? For example:
cout << "String that includes a <some way of iserting the £ sign> sign";
£
does not have an "ASCII code" - ASCII is 7 bits (0..127). There are various extended 8 bit characters sets which include £
but there is no single standard for this and the £
symbol may have various different values in different environments. You should probably be using Unicode if you need international symbols with maximum portability.
Yep. However, you might try
std::wcout << L"String that includes a £ sign";
. Depending on your platform, this might work.For clarification. In Visual Studio: Project -> Properties ->Configuration Properties -> General -> Change "Character Set" from "Use Multi-Byte Character Set" To "Use Unicode Character Set"