To get certain special characters in C++ we can enclose an escape sequence of octal values within single quotes thus '\nnn'
where nnn
is an octal code.
The only example I currently know of is '\370'
for the degree symbol (°).
Where is a list of other such values for printing non-simple-ascii characters in C++?
In a code table at ascii-code.com are these two entries
DEC OCT HEX BIN Symbol HTML Number HTML Name Description
176 260 B0 10110000 ° ° ° Degree sign
248 370 F8 11111000 ø ø ø Latin small letter o with slash
which are clearly not correct for my problem – i.e., assigning '\nnn'
to a char
variable or inserting to an outputstream via cout <<
in Visual Studio 2015.
Where is a correct table? It has something to do with "codesets" but I don't know what codeset is the default in VS 2015 or how to change the codeset.
It was suggested below that I "use \u####
where ####
is a number representing the Unicode value of the wanted character. For example \u2014
will print an — (em-dash)." However, when I try that example – or any others from rapidtables.com/code/text/unicode-characters or wikipedia.org/wiki/List_of_Unicode_characters – I don't get the character expected for the given code. For example, \20AC
should produce a Euro sign (€) but I get a big C with cedilla (Ç). Where is the table of Unicode values for printing special characters in C++ in Visual Studio 2015?
ISO-8859-1
codeset. What codeset are you using?\u####
where####
is a number representing the Unicode value of the wanted character. For example\u2014
will print an — (em-dash).