Escape Sequences
RWUString provides the unescape()
method that replaces hexadecimal character escapes with their corresponding Unicode characters. The recognized escape sequences are shown in Table 158. The value of any other escape sequence is the value of the character that follows the backslash.
Escape Sequence |
Unicode |
|
4 hexadecimal digits in the range |
|
8 hexadecimal digits |
|
1 or 2 hexadecimal digits |
|
1, 2, or 3 octal digits in the range |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note that when you create an RWUString from a string literal containing an escaped character, you must use a double-backslash sequence to escape characters, as the C++ compiler itself treats the \
character as special, denoting the beginning of an escape sequence embedded in the C++ source code. For example:
RWUToUnicodeConverter fromAscii("US-ASCII");
RWUString str("clich\\u00e9", fromAscii);
RWUFromUnicodeConverter toAscii("US-ASCII");
std::cout << str.toBytes(toAscii) << std::endl;
std::cout << str.unescape().toBytes(toAscii) << std::endl;
Results:
========
clich\u00e9
cliché
If an escape sequence is ill-formed, unescape()
throws an RWConversionErr. (See this class entry in the SourcePro C++ API Reference Guide.)