diff options
author | Jose <jose@zeroc.com> | 2019-03-02 21:08:05 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-03-02 21:08:05 +0100 |
commit | f35adac9c83ebb0f1c4173548007a3b8dbafec74 (patch) | |
tree | cbd179e81418fbc2385eac406efd4cc7028f02b9 /cpp/src/Slice/StringLiteralUtil.cpp | |
parent | Swift properties test (diff) | |
download | ice-f35adac9c83ebb0f1c4173548007a3b8dbafec74.tar.bz2 ice-f35adac9c83ebb0f1c4173548007a3b8dbafec74.tar.xz ice-f35adac9c83ebb0f1c4173548007a3b8dbafec74.zip |
Swift string literal support
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); |