The error you get is related to 2.2 / 2 in C ++ 03:
If the hexadecimal value for the universal symbolic name is less than 0x20 or in the range 0x7F-0x9F (inclusive), or if the universal symbolic name indicates the symbol in the main symbol of the set source, then the program is poorly formed.
So, for a string literal, you need to use \x1 or \1 instead (and you can add zero zeros to it). Alternatively, if you only need one character in your string:
string s; s.push_back(1);
or
string s(1,1);
The restriction is relaxed in C ++ 11 (2.3 / 2):
if the hexadecimal value for the universal name character outside c is a char sequence, s is a char sequence or r is a char sequence or a String literal matches a control character (in either of the ranges 0x00-0x1F or 0x7F-0x9F, both inclusive) or character in the main character set of the source, the program is poorly formed.
source share