Reputation: 45
Simply can I make raw string which has alert character \a
or unicode \u002f
character?
If yes, then how the escaping is done without \
?
If no, then are raw strings only used for printable characters? Is my understanding right?
This was a simple question, but this site requires more info, so I just want to say that I read about 30 web pages regarding raw string in C++ and python, and also the C++ by Stroustrup and did not find any sentence saying that raw strings are only used for printable character.
And all examples use "
or real new line by pressing enter on keyboard "which must have been converted to a literal to be incorporated in raw string>>>what is this literal?"
The last phrase means that when different authors give example of difference between ordinary string and raw string they say that raw string can have double quotes and backslash without escaping character ....
Also raw string can have new line without \n symbol >>>this will be accomplished during texting by pressing enter button on keyboard.
But how about other non printable characters like \a and unicode code points? this is what my question is about??
So my question is about concept not about certain code or example.
Again simply: do raw strings have ability to include alert character or unicode code points?
Can i convert string s=u8"hello world \a"
to string s = u8R"(hello world \a)"
where alert sound happens at the end in both strings ????
Upvotes: 3
Views: 1188
Reputation: 31599
You cannot use any escape characters in raw strings. The following line is printed as is
std::cout << R"(\t\aline1\nline2\n)"
output: \t\aline1\nline2\n
You can, however, exit the raw string and go back in, in the same line of code. For example, the following line will connect raw strings with escape characters:
std::string s = "\t\a" u8R"(line1)" "\n" R"(line2)" "\n";
Upvotes: 5