diff options
Diffstat (limited to 'cpp/src/Slice/StringLiteralUtil.cpp')
-rw-r--r-- | cpp/src/Slice/StringLiteralUtil.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/cpp/src/Slice/StringLiteralUtil.cpp b/cpp/src/Slice/StringLiteralUtil.cpp index 00c4af6efd6..db6885a8f0c 100644 --- a/cpp/src/Slice/StringLiteralUtil.cpp +++ b/cpp/src/Slice/StringLiteralUtil.cpp @@ -197,6 +197,11 @@ StringLiteralGenerator::escapeASCIIChar(char c) os << "\\" << oct << setfill('0') << setw(3) << static_cast<unsigned int>(c & 0xFF); _format = OctalFormat; } + else if(_escapeMode == EC6UCN) + { + os << "\\u{" << hex << setfill('0') << setw(4) << static_cast<unsigned int>(c & 0xFF) << "}"; + _format = HexFormat; + } else { os << _shortUCNPrefix << hex << setfill('0') << setw(4) << static_cast<unsigned int>(c & 0xFF); @@ -231,7 +236,11 @@ StringLiteralGenerator::escapeCodePoint(unsigned int codePoint) else { ostringstream os; - if(codePoint < _cutOff) + if(_escapeMode == EC6UCN) + { + os << "\\u{" << hex << codePoint << "}"; + } + else if(codePoint < _cutOff) { // // Output octal escape @@ -255,10 +264,6 @@ StringLiteralGenerator::escapeCodePoint(unsigned int codePoint) os << _shortUCNPrefix << setfill('0') << setw(4) << hex << lowSurrogate; _format = HexFormat; } - else if(_escapeMode == EC6UCN) - { - os << "\\u{" << hex << codePoint << "}"; - } else { os << "\\U" << setfill('0') << setw(8) << hex << codePoint; @@ -360,7 +365,7 @@ Slice::toStringLiteral(const string& value, // keep this escape as is os << "\\" << c << codePointStr; } - else if(c == 'u') + else if(c == 'u' && escapeMode != EC6UCN) { os << (escapeMode == Matlab ? "\\x" : "\\u") << codePointStr; generator.format(StringLiteralGenerator::HexFormat); |