diff options
33 files changed, 1011 insertions, 95 deletions
diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp index 7bad1d67c17..ca36a912b47 100644 --- a/cpp/src/IceUtil/Unicode.cpp +++ b/cpp/src/IceUtil/Unicode.cpp @@ -147,6 +147,24 @@ IceUtilInternal::convertUTF8ToUTF16(const vector<unsigned char>& source, vector< } ConversionResult +IceUtilInternal::convertUTF8ToUTF32(const vector<unsigned char>& source, vector<unsigned int>& target, ConversionFlags flags) +{ + target.resize(source.size()); + const unsigned char* sourceStart = &source[0]; + const unsigned char* sourceEnd = &source[0] + source.size(); + + unsigned int* targetStart = &target[0]; + unsigned int* targetEnd = &target[0] + target.size(); + ConversionResult result = ConvertUTF8toUTF32(&sourceStart, sourceEnd, &targetStart, targetEnd, flags); + + if(result == conversionOK) + { + target.resize(targetStart - &target[0]); + } + return result; +} + +ConversionResult IceUtilInternal::convertUTF32ToUTF8(const vector<unsigned int>& source, vector<unsigned char>& target, ConversionFlags flags) { target.resize(source.size() * 4); diff --git a/cpp/src/IceUtil/Unicode.h b/cpp/src/IceUtil/Unicode.h index 2c96d6c6448..d5c3b235ddb 100644 --- a/cpp/src/IceUtil/Unicode.h +++ b/cpp/src/IceUtil/Unicode.h @@ -50,6 +50,10 @@ convertUTF8ToUTF16(const std::vector<unsigned char>&, std::vector<unsigned short IceUtil::ConversionFlags); ICE_UTIL_API ConversionResult +convertUTF8ToUTF32(const std::vector<unsigned char>&, std::vector<unsigned int>&, + IceUtil::ConversionFlags); + +ICE_UTIL_API ConversionResult convertUTF32ToUTF8(const std::vector<unsigned int>&, std::vector<unsigned char>&, IceUtil::ConversionFlags); diff --git a/cpp/src/Slice/Ruby.cpp b/cpp/src/Slice/Ruby.cpp index 62daa345cbf..209711a679d 100644 --- a/cpp/src/Slice/Ruby.cpp +++ b/cpp/src/Slice/Ruby.cpp @@ -301,7 +301,10 @@ Slice::Ruby::compile(int argc, char* argv[]) throw FileException(__FILE__, __LINE__, os.str()); } FileTracker::instance()->addFile(file); - + // + // Ruby magic comment to set the file encoding, it must be first or second line + // + out << "# encoding: utf-8\n"; printHeader(out); printGeneratedHeader(out, base + ".ice", "#"); diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp index 38bbeb5da19..3639a53b185 100644 --- a/cpp/src/Slice/RubyUtil.cpp +++ b/cpp/src/Slice/RubyUtil.cpp @@ -1601,7 +1601,7 @@ Slice::Ruby::CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTr ++i; } - _out << "\".force_encoding(\"utf-8\")"; // Closing " + _out << "\""; // Closing " break; } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index d93c457bf9e..5df28c48df2 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -32,6 +32,45 @@ namespace { string +u32CodePoint(unsigned int value) +{ + ostringstream s; + s << "\\U"; + s << hex; + s.width(8); + s.fill('0'); + s << value; + return s.str(); +} + + +void +writeU8Buffer(const vector<unsigned char>& u8buffer, ::IceUtilInternal::Output& out) +{ + vector<unsigned int> u32buffer; + IceUtilInternal::ConversionResult result = convertUTF8ToUTF32(u8buffer, u32buffer, IceUtil::lenientConversion); + switch(result) + { + case conversionOK: + break; + case sourceExhausted: + throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted"); + case sourceIllegal: + throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal"); + default: + { + assert(0); + throw IceUtil::IllegalConversionException(__FILE__, __LINE__); + } + } + + for(vector<unsigned int>::const_iterator c = u32buffer.begin(); c != u32buffer.end(); ++c) + { + out << u32CodePoint(*c); + } +} + +string getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2) { string deprecateMetadata, deprecateSymbol; @@ -74,115 +113,173 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt if((useWstring & TypeContextUseWstring) || findMetaData(metaData) == "wstring") { - out << 'L'; - } - out << "\""; // Opening " + // + // Wide strings + // + vector<unsigned char> u8buffer; // Buffer to convert multibyte characters - for(size_t i = 0; i < value.size();) - { - if(charSet.find(value[i]) == charSet.end()) + out << "L\""; + for(size_t i = 0; i < value.size();) + { + if(charSet.find(value[i]) == charSet.end()) + { + if(static_cast<unsigned char>(value[i]) < 128) // Single byte character + { + // + // Print as unicode if not in basic source character set + // + out << u32CodePoint(static_cast<unsigned int>(value[i])); + } + else + { + u8buffer.push_back(value[i]); + } + } + else + { + // + // Write any pedding characters in the utf8 buffer + // + if(!u8buffer.empty()) + { + writeU8Buffer(u8buffer, out); + u8buffer.clear(); + } + + switch(value[i]) + { + case '"': + { + out << "\\"; + break; + } + } + + out << value[i]; // Print normally if in basic source character set + } + i++; + + } + + // + // Write any pedding characters in the utf8 buffer + // + if(!u8buffer.empty()) { - unsigned char uc = value[i]; // char may be signed, so make it positive - ostringstream s; - s << "\\"; // Print as octal if not in basic source character set - s.width(3); - s.fill('0'); - s << oct; - s << static_cast<unsigned>(uc); - out << s.str(); + writeU8Buffer(u8buffer, out); + u8buffer.clear(); } - else + out << "\""; + } + else // narrow strings + { + out << "\""; // Opening " + + for(size_t i = 0; i < value.size();) { - switch(value[i]) + if(charSet.find(value[i]) == charSet.end()) + { + unsigned char uc = value[i]; // char may be signed, so make it positive + ostringstream s; + s << "\\"; // Print as octal if not in basic source character set + s.width(3); + s.fill('0'); + s << oct; + s << static_cast<unsigned>(uc); + out << s.str(); + } + else { - case '\\': + switch(value[i]) { - string s = "\\"; - size_t j = i + 1; - for(; j < value.size(); ++j) + case '\\': { - if(value[j] != '\\') + string s = "\\"; + size_t j = i + 1; + for(; j < value.size(); ++j) { - break; + if(value[j] != '\\') + { + break; + } + s += "\\"; } - s += "\\"; - } - // - // An even number of slash \ will escape the backslash and - // the codepoint will be interpreted as its charaters - // - // \\U00000041 - ['\\', 'U', '0', '0', '0', '0', '0', '0', '4', '1'] - // \\\U00000041 - ['\\', 'A'] (41 is the codepoint for 'A') - // - if(s.size() % 2 != 0 && (value[j] == 'U' || value[j] == 'u')) - { // - // Convert codepoint to UTF8 bytes and write the escaped bytes + // An even number of slash \ will escape the backslash and + // the codepoint will be interpreted as its charaters + // + // \\U00000041 - ['\\', 'U', '0', '0', '0', '0', '0', '0', '4', '1'] + // \\\U00000041 - ['\\', 'A'] (41 is the codepoint for 'A') // - out << s.substr(0, s.size() - 1); + if(s.size() % 2 != 0 && (value[j] == 'U' || value[j] == 'u')) + { + // + // Convert codepoint to UTF8 bytes and write the escaped bytes + // + out << s.substr(0, s.size() - 1); - size_t sz = value[j] == 'U' ? 8 : 4; - string codepoint = value.substr(j + 1, sz); - assert(codepoint.size() == sz); + size_t sz = value[j] == 'U' ? 8 : 4; + string codepoint = value.substr(j + 1, sz); + assert(codepoint.size() == sz); - IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16); + IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16); - vector<unsigned int> u32buffer; - u32buffer.push_back(static_cast<unsigned int>(v)); + vector<unsigned int> u32buffer; + u32buffer.push_back(static_cast<unsigned int>(v)); - vector<unsigned char> u8buffer; + vector<unsigned char> u8buffer; - IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion); - switch(result) - { - case conversionOK: - break; - case sourceExhausted: - throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted"); - case sourceIllegal: - throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal"); - default: + IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion); + switch(result) { - assert(0); - throw IceUtil::IllegalConversionException(__FILE__, __LINE__); + case conversionOK: + break; + case sourceExhausted: + throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted"); + case sourceIllegal: + throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal"); + default: + { + assert(0); + throw IceUtil::IllegalConversionException(__FILE__, __LINE__); + } } - } - ostringstream s; - for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q) + ostringstream s; + for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q) + { + s << "\\"; + s.fill('0'); + s.width(3); + s << oct; + s << static_cast<unsigned int>(*q); + } + out << s.str(); + + i = j + 1 + sz; + } + else { - s << "\\"; - s.fill('0'); - s.width(3); - s << oct; - s << static_cast<unsigned int>(*q); + out << s; + i = j; } - out << s.str(); - - i = j + 1 + sz; + continue; } - else + case '"': { - out << s; - i = j; + out << "\\"; + break; } - continue; - } - case '"': - { - out << "\\"; - break; } + + out << value[i]; // Print normally if in basic source character set } - - out << value[i]; // Print normally if in basic source character set + ++i; } - ++i; + out << "\""; // Closing " } - - out << "\""; // Closing " } else if(bp && bp->kind() == Builtin::KindLong) { diff --git a/cpp/src/slice2objc/Gen.cpp b/cpp/src/slice2objc/Gen.cpp index 283efc935e3..1363779f8e9 100644 --- a/cpp/src/slice2objc/Gen.cpp +++ b/cpp/src/slice2objc/Gen.cpp @@ -17,6 +17,8 @@ #include <direct.h> #endif #include <IceUtil/Iterator.h> +#include <IceUtil/Unicode.h> +#include <IceUtil/InputUtil.h> #include <IceUtil/UUID.h> #include <Slice/Checksum.h> #include <Slice/FileTracker.h> @@ -1492,13 +1494,13 @@ Slice::Gen::TypesVisitor::writeConstantValue(IceUtilInternal::Output& out, const out << "@\""; // Opening @" - for(string::const_iterator c = val.begin(); c != val.end(); ++c) + for(size_t i = 0; i < val.size();) { - if(charSet.find(*c) == charSet.end()) + if(charSet.find(val[i]) == charSet.end()) { - unsigned char uc = *c; // char may be signed, so make it positive + unsigned char uc = val[i]; // char may be signed, so make it positive ostringstream s; - s << "\\"; // Print as octal if not in basic source character set + s << "\\"; // Print as octal if not in basic source character set s.width(3); s.fill('0'); s << oct; @@ -1507,11 +1509,95 @@ Slice::Gen::TypesVisitor::writeConstantValue(IceUtilInternal::Output& out, const } else { - out << *c; // Print normally if in basic source character set + switch(val[i]) + { + case '\\': + { + string s = "\\"; + size_t j = i + 1; + for(; j < val.size(); ++j) + { + if(val[j] != '\\') + { + break; + } + s += "\\"; + } + + // + // An even number of slash \ will escape the backslash and + // the codepoint will be interpreted as its charaters + // + // \\U00000041 - ['\\', 'U', '0', '0', '0', '0', '0', '0', '4', '1'] + // \\\U00000041 - ['\\', 'A'] (41 is the codepoint for 'A') + // + if(s.size() % 2 != 0 && (val[j] == 'U' || val[j] == 'u')) + { + // + // Convert codepoint to UTF8 bytes and write the escaped bytes + // + out << s.substr(0, s.size() - 1); + + size_t sz = val[j] == 'U' ? 8 : 4; + string codepoint = val.substr(j + 1, sz); + assert(codepoint.size() == sz); + + IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16); + + + vector<unsigned int> u32buffer; + u32buffer.push_back(static_cast<unsigned int>(v)); + + vector<unsigned char> u8buffer; + + IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion); + switch(result) + { + case conversionOK: + break; + case sourceExhausted: + throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted"); + case sourceIllegal: + throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal"); + default: + { + assert(0); + throw IceUtil::IllegalConversionException(__FILE__, __LINE__); + } + } + + ostringstream s; + for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q) + { + s << "\\"; + s.fill('0'); + s.width(3); + s << oct; + s << static_cast<unsigned int>(*q); + } + out << s.str(); + + i = j + 1 + sz; + } + else + { + out << s; + i = j; + } + continue; + } + case '"': + { + out << "\\"; + break; + } + } + + out << val[i]; // Print normally if in basic source character set } + ++i; } - - out << "\""; // Closing " + out << "\""; // Closing " } else { diff --git a/cpp/test/Ice/operations/Test.ice b/cpp/test/Ice/operations/Test.ice index cf44e14a50d..d7698951ca8 100644 --- a/cpp/test/Ice/operations/Test.ice +++ b/cpp/test/Ice/operations/Test.ice @@ -43,6 +43,7 @@ sequence<long> LongS; sequence<float> FloatS; sequence<double> DoubleS; sequence<string> StringS; +sequence<["cpp:type:wstring"]string> WStringS; sequence<MyEnum> MyEnumS; sequence<MyClass*> MyClassS; @@ -253,6 +254,7 @@ class MyClass ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); StringS opStringLiterals(); + WStringS opWStringLiterals(); }; struct MyStruct1 @@ -341,5 +343,70 @@ const string su0 = "ÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; const string su1 = "\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; const string su2 = "\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +// +// Wide string literals +// + +const ["cpp:type:wstring"]string ws0 = "\u005c"; // backslash +const ["cpp:type:wstring"]string ws1 = "\u0041"; // A +const ["cpp:type:wstring"]string ws2 = "\u0049\u0063\u0065"; // Ice +const ["cpp:type:wstring"]string ws3 = "\u004121"; // A21 +const ["cpp:type:wstring"]string ws4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041 +const ["cpp:type:wstring"]string ws5 = "\u00FF"; // ÿ +const ["cpp:type:wstring"]string ws6 = "\u03FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF) +const ["cpp:type:wstring"]string ws7 = "\u05F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0) +const ["cpp:type:wstring"]string ws8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000) +const ["cpp:type:wstring"]string ws9 = "\U0001F34C"; // BANANA (U+1F34C) +const ["cpp:type:wstring"]string ws10 = "\u0DA7"; // Sinhala Letter Alpapraana Ttayanna + +const ["cpp:type:wstring"]string wsw0 = "\U0000005c"; // backslash +const ["cpp:type:wstring"]string wsw1 = "\U00000041"; // A +const ["cpp:type:wstring"]string wsw2 = "\U00000049\U00000063\U00000065"; // Ice +const ["cpp:type:wstring"]string wsw3 = "\U0000004121"; // A21 +const ["cpp:type:wstring"]string wsw4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041 +const ["cpp:type:wstring"]string wsw5 = "\U000000FF"; // ÿ +const ["cpp:type:wstring"]string wsw6 = "\U000003FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF) +const ["cpp:type:wstring"]string wsw7 = "\U000005F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0) +const ["cpp:type:wstring"]string wsw8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000) +const ["cpp:type:wstring"]string wsw9 = "\U0001F34C"; // BANANA (U+1F34C) +const ["cpp:type:wstring"]string wsw10 = "\U00000DA7"; // Sinhala Letter Alpapraana Ttayanna + +/** +\' single quote byte 0x27 in ASCII encoding +\" double quote byte 0x22 in ASCII encoding +\? question mark byte 0x3f in ASCII encoding +\\ backslash byte 0x5c in ASCII encoding +\a audible bell byte 0x07 in ASCII encoding +\b backspace byte 0x08 in ASCII encoding +\f form feed - new page byte 0x0c in ASCII encoding +\n line feed - new line byte 0x0a in ASCII encoding +\r carriage return byte 0x0d in ASCII encoding +\t horizontal tab byte 0x09 in ASCII encoding +\v vertical tab byte 0x0b in ASCII encoding +**/ + +const ["cpp:type:wstring"]string wss0 = "\'\"\?\\\a\b\f\n\r\t\v"; +const ["cpp:type:wstring"]string wss1 = "\u0027\u0022\u003f\u005c\u0007\u0008\u000c\u000a\u000d\u0009\u000b"; +const ["cpp:type:wstring"]string wss2 = "\U00000027\U00000022\U0000003f\U0000005c\U00000007\U00000008\U0000000c\U0000000a\U0000000d\U00000009\U0000000b"; + +const ["cpp:type:wstring"]string wss3 = "\\\\U\\u\\"; /* \\U\u\ */ +const ["cpp:type:wstring"]string wss4 = "\\\u0041\\"; /* \A\ */ +const ["cpp:type:wstring"]string wss5 = "\\u0041\\"; /* \u0041\ */ + +// +// ÿ - Unicode Character 'LATIN SMALL LETTER Y WITH DIAERESIS' (U+00FF) +// Ā - Unicode Character 'LATIN CAPITAL LETTER A WITH MACRON' (U+0100) +// ἀ - Unicode Character 'GREEK SMALL LETTER ALPHA WITH PSILI' (U+1F00) +// 𐆔 - Unicode Character 'ROMAN DIMIDIA SEXTULA SIGN' (U+10194) +// 𐅪 - Unicode Character 'GREEK ACROPHONIC THESPIAN ONE HUNDRED' (U+1016A) +// 𐆘 - Unicode Character 'ROMAN SESTERTIUS SIGN' (U+10198) +// 🍀 - Unicode Character 'FOUR LEAF CLOVER' (U+1F340) +// 🍁 - Unicode Character 'MAPLE LEAF' (U+1F341) +// 🍂 - Unicode Character 'FALLEN LEAF' (U+1F342) +// 🍃 - Unicode Character 'LEAF FLUTTERING IN WIND' (U+1F343) +const ["cpp:type:wstring"]string wsu0 = "ÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; +const ["cpp:type:wstring"]string wsu1 = "\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +const ["cpp:type:wstring"]string wsu2 = "\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; + }; diff --git a/cpp/test/Ice/operations/TestAMD.ice b/cpp/test/Ice/operations/TestAMD.ice index a65608ea4c7..ee26d1c1970 100644 --- a/cpp/test/Ice/operations/TestAMD.ice +++ b/cpp/test/Ice/operations/TestAMD.ice @@ -43,6 +43,7 @@ sequence<long> LongS; sequence<float> FloatS; sequence<double> DoubleS; sequence<string> StringS; +sequence<["cpp:type:wstring"] string> WStringS; sequence<MyEnum> MyEnumS; sequence<MyClass*> MyClassS; @@ -254,6 +255,8 @@ dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD; ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); StringS opStringLiterals(); + + WStringS opWStringLiterals(); }; struct MyStruct1 @@ -344,6 +347,71 @@ const string su0 = "ÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; const string su1 = "\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; const string su2 = "\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +// +// Wide string literals +// + +const ["cpp:type:wstring"]string ws0 = "\u005c"; // backslash +const ["cpp:type:wstring"]string ws1 = "\u0041"; // A +const ["cpp:type:wstring"]string ws2 = "\u0049\u0063\u0065"; // Ice +const ["cpp:type:wstring"]string ws3 = "\u004121"; // A21 +const ["cpp:type:wstring"]string ws4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041 +const ["cpp:type:wstring"]string ws5 = "\u00FF"; // ÿ +const ["cpp:type:wstring"]string ws6 = "\u03FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF) +const ["cpp:type:wstring"]string ws7 = "\u05F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0) +const ["cpp:type:wstring"]string ws8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000) +const ["cpp:type:wstring"]string ws9 = "\U0001F34C"; // BANANA (U+1F34C) +const ["cpp:type:wstring"]string ws10 = "\u0DA7"; // Sinhala Letter Alpapraana Ttayanna + +const ["cpp:type:wstring"]string wsw0 = "\U0000005c"; // backslash +const ["cpp:type:wstring"]string wsw1 = "\U00000041"; // A +const ["cpp:type:wstring"]string wsw2 = "\U00000049\U00000063\U00000065"; // Ice +const ["cpp:type:wstring"]string wsw3 = "\U0000004121"; // A21 +const ["cpp:type:wstring"]string wsw4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041 +const ["cpp:type:wstring"]string wsw5 = "\U000000FF"; // ÿ +const ["cpp:type:wstring"]string wsw6 = "\U000003FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF) +const ["cpp:type:wstring"]string wsw7 = "\U000005F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0) +const ["cpp:type:wstring"]string wsw8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000) +const ["cpp:type:wstring"]string wsw9 = "\U0001F34C"; // BANANA (U+1F34C) +const ["cpp:type:wstring"]string wsw10 = "\U00000DA7"; // Sinhala Letter Alpapraana Ttayanna + +/** +\' single quote byte 0x27 in ASCII encoding +\" double quote byte 0x22 in ASCII encoding +\? question mark byte 0x3f in ASCII encoding +\\ backslash byte 0x5c in ASCII encoding +\a audible bell byte 0x07 in ASCII encoding +\b backspace byte 0x08 in ASCII encoding +\f form feed - new page byte 0x0c in ASCII encoding +\n line feed - new line byte 0x0a in ASCII encoding +\r carriage return byte 0x0d in ASCII encoding +\t horizontal tab byte 0x09 in ASCII encoding +\v vertical tab byte 0x0b in ASCII encoding +**/ + +const ["cpp:type:wstring"]string wss0 = "\'\"\?\\\a\b\f\n\r\t\v"; +const ["cpp:type:wstring"]string wss1 = "\u0027\u0022\u003f\u005c\u0007\u0008\u000c\u000a\u000d\u0009\u000b"; +const ["cpp:type:wstring"]string wss2 = "\U00000027\U00000022\U0000003f\U0000005c\U00000007\U00000008\U0000000c\U0000000a\U0000000d\U00000009\U0000000b"; + +const ["cpp:type:wstring"]string wss3 = "\\\\U\\u\\"; /* \\U\u\ */ +const ["cpp:type:wstring"]string wss4 = "\\\u0041\\"; /* \A\ */ +const ["cpp:type:wstring"]string wss5 = "\\u0041\\"; /* \u0041\ */ + +// +// ÿ - Unicode Character 'LATIN SMALL LETTER Y WITH DIAERESIS' (U+00FF) +// Ā - Unicode Character 'LATIN CAPITAL LETTER A WITH MACRON' (U+0100) +// ἀ - Unicode Character 'GREEK SMALL LETTER ALPHA WITH PSILI' (U+1F00) +// 𐆔 - Unicode Character 'ROMAN DIMIDIA SEXTULA SIGN' (U+10194) +// 𐅪 - Unicode Character 'GREEK ACROPHONIC THESPIAN ONE HUNDRED' (U+1016A) +// 𐆘 - Unicode Character 'ROMAN SESTERTIUS SIGN' (U+10198) +// 🍀 - Unicode Character 'FOUR LEAF CLOVER' (U+1F340) +// 🍁 - Unicode Character 'MAPLE LEAF' (U+1F341) +// 🍂 - Unicode Character 'FALLEN LEAF' (U+1F342) +// 🍃 - Unicode Character 'LEAF FLUTTERING IN WIND' (U+1F343) +const ["cpp:type:wstring"]string wsu0 = "ÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; +const ["cpp:type:wstring"]string wsu1 = "\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +const ["cpp:type:wstring"]string wsu2 = "\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; + }; diff --git a/cpp/test/Ice/operations/TestAMDI.cpp b/cpp/test/Ice/operations/TestAMDI.cpp index df030eb030d..419320fdcc4 100644 --- a/cpp/test/Ice/operations/TestAMDI.cpp +++ b/cpp/test/Ice/operations/TestAMDI.cpp @@ -780,7 +780,6 @@ MyDerivedClassI::opMyClass1_async(const Test::AMD_MyDerivedClass_opMyClass1Ptr& cb->ice_response(c); } - void MyDerivedClassI::opStringLiterals_async(const Test::AMD_MyClass_opStringLiteralsPtr& cb, const Ice::Current&) @@ -821,4 +820,46 @@ MyDerivedClassI::opStringLiterals_async(const Test::AMD_MyClass_opStringLiterals data.push_back(Test::su1); data.push_back(Test::su2); cb->ice_response(data); -}
\ No newline at end of file +} + +void +MyDerivedClassI::opWStringLiterals_async(const Test::AMD_MyClass_opWStringLiteralsPtr& cb, + const Ice::Current&) +{ + Test::WStringS data; + data.push_back(Test::ws0); + data.push_back(Test::ws1); + data.push_back(Test::ws2); + data.push_back(Test::ws3); + data.push_back(Test::ws4); + data.push_back(Test::ws5); + data.push_back(Test::ws6); + data.push_back(Test::ws7); + data.push_back(Test::ws8); + data.push_back(Test::ws9); + data.push_back(Test::ws10); + + data.push_back(Test::wsw0); + data.push_back(Test::wsw1); + data.push_back(Test::wsw2); + data.push_back(Test::wsw3); + data.push_back(Test::wsw4); + data.push_back(Test::wsw5); + data.push_back(Test::wsw6); + data.push_back(Test::wsw7); + data.push_back(Test::wsw8); + data.push_back(Test::wsw9); + data.push_back(Test::wsw10); + + data.push_back(Test::wss0); + data.push_back(Test::wss1); + data.push_back(Test::wss2); + data.push_back(Test::wss3); + data.push_back(Test::wss4); + data.push_back(Test::wss5); + + data.push_back(Test::wsu0); + data.push_back(Test::wsu1); + data.push_back(Test::wsu2); + cb->ice_response(data); +} diff --git a/cpp/test/Ice/operations/TestAMDI.h b/cpp/test/Ice/operations/TestAMDI.h index 418d0a2aa36..686a76f00cd 100644 --- a/cpp/test/Ice/operations/TestAMDI.h +++ b/cpp/test/Ice/operations/TestAMDI.h @@ -278,6 +278,9 @@ public: virtual void opStringLiterals_async(const Test::AMD_MyClass_opStringLiteralsPtr&, const Ice::Current&); + + virtual void opWStringLiterals_async(const Test::AMD_MyClass_opWStringLiteralsPtr&, + const Ice::Current&); private: IceUtil::ThreadPtr _opVoidThread; diff --git a/cpp/test/Ice/operations/TestI.cpp b/cpp/test/Ice/operations/TestI.cpp index 29e6728047b..84054ac8d45 100644 --- a/cpp/test/Ice/operations/TestI.cpp +++ b/cpp/test/Ice/operations/TestI.cpp @@ -782,3 +782,46 @@ MyDerivedClassI::opStringLiterals(const Ice::Current&) return data; } + +Test::WStringS +MyDerivedClassI::opWStringLiterals(const Ice::Current&) +{ + Test::WStringS data; + data.push_back(Test::ws0); + data.push_back(Test::ws1); + data.push_back(Test::ws2); + data.push_back(Test::ws3); + data.push_back(Test::ws4); + data.push_back(Test::ws5); + data.push_back(Test::ws6); + data.push_back(Test::ws7); + data.push_back(Test::ws8); + data.push_back(Test::ws9); + data.push_back(Test::ws10); + + data.push_back(Test::wsw0); + data.push_back(Test::wsw1); + data.push_back(Test::wsw2); + data.push_back(Test::wsw3); + data.push_back(Test::wsw4); + data.push_back(Test::wsw5); + data.push_back(Test::wsw6); + data.push_back(Test::wsw7); + data.push_back(Test::wsw8); + data.push_back(Test::wsw9); + data.push_back(Test::wsw10); + + data.push_back(Test::wss0); + data.push_back(Test::wss1); + data.push_back(Test::wss2); + data.push_back(Test::wss3); + data.push_back(Test::wss4); + data.push_back(Test::wss5); + + data.push_back(Test::wsu0); + data.push_back(Test::wsu1); + data.push_back(Test::wsu2); + + return data; +} + diff --git a/cpp/test/Ice/operations/TestI.h b/cpp/test/Ice/operations/TestI.h index 4f31f7eecfe..8f8b0b1b573 100644 --- a/cpp/test/Ice/operations/TestI.h +++ b/cpp/test/Ice/operations/TestI.h @@ -270,6 +270,8 @@ public: virtual Test::MyClass1Ptr opMyClass1(const Test::MyClass1Ptr&, const Ice::Current&); virtual Test::StringS opStringLiterals(const Ice::Current&); + + virtual Test::WStringS opWStringLiterals(const Ice::Current&); private: diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp index 54d2d2d439a..379d808c520 100644 --- a/cpp/test/Ice/operations/Twoways.cpp +++ b/cpp/test/Ice/operations/Twoways.cpp @@ -135,11 +135,93 @@ twoways(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p) test(Test::ss5 == "\\u0041\\" && Test::ss5 == literals[27]); - test(Test::su0 == Test::su1); - test(Test::su0 == Test::su2); - test(Test::su0 == literals[28]); - test(Test::su0 == literals[29]); - test(Test::su0 == literals[30]); + test(Test::su0 == Test::su1 && + Test::su0 == Test::su2 && + Test::su0 == literals[28] && + Test::su0 == literals[29] && + Test::su0 == literals[30]); + + // + // Same but using wide strings + // + Test::WStringS wliterals = p->opWStringLiterals(); + + test(Test::ws0 == L"\\" && + Test::ws0 == Test::wsw0 && + Test::ws0 == wliterals[0] && + Test::ws0 == wliterals[11]); + + test(Test::ws1 == L"A" && + Test::ws1 == Test::wsw1 && + Test::ws1 == wliterals[1] && + Test::ws1 == wliterals[12]); + + test(Test::ws2 == L"Ice" && + Test::ws2 == Test::wsw2 && + Test::ws2 == wliterals[2] && + Test::ws2 == wliterals[13]); + + test(Test::ws3 == L"A21" && + Test::ws3 == Test::wsw3 && + Test::ws3 == wliterals[3] && + Test::ws3 == wliterals[14]); + + test(Test::ws4 == L"\\u0041 \\U00000041" && + Test::ws4 == Test::wsw4 && + Test::ws4 == wliterals[4] && + Test::ws4 == wliterals[15]); + + test(Test::ws5 == L"\u00FF" && + Test::ws5 == Test::wsw5 && + Test::ws5 == wliterals[5] && + Test::ws5 == wliterals[16]); + + test(Test::ws6 == L"\u03FF" && + Test::ws6 == Test::wsw6 && + Test::ws6 == wliterals[6] && + Test::ws6 == wliterals[17]); + + test(Test::ws7 == L"\u05F0" && + Test::ws7 == Test::wsw7 && + Test::ws7 == wliterals[7] && + Test::ws7 == wliterals[18]); + + test(Test::ws8 == L"\U00010000" && + Test::ws8 == Test::wsw8 && + Test::ws8 == wliterals[8] && + Test::ws8 == wliterals[19]); + + test(Test::ws9 == L"\U0001F34C" && + Test::ws9 == Test::wsw9 && + Test::ws9 == wliterals[9] && + Test::ws9 == wliterals[20]); + + test(Test::ws10 == L"\u0DA7" && + Test::ws10 == Test::wsw10 && + Test::ws10 == wliterals[10] && + Test::ws10 == wliterals[21]); + + test(Test::wss0 == L"\'\"\?\\\a\b\f\n\r\t\v" && + Test::wss0 == Test::wss1 && + Test::wss0 == Test::wss2 && + Test::wss0 == wliterals[22] && + Test::wss0 == wliterals[23] && + Test::wss0 == wliterals[24]); + + test(Test::wss3 == L"\\\\U\\u\\" && + Test::wss3 == wliterals[25]); + + test(Test::wss4 == L"\\A\\" && + Test::wss4 == wliterals[26]); + + test(Test::wss5 == L"\\u0041\\" && + Test::wss5 == wliterals[27]); + + test(Test::wsu0 == Test::wsu1 && + Test::wsu0 == Test::wsu2 && + Test::wsu0 == wliterals[28] && + Test::wsu0 == wliterals[29] && + Test::wsu0 == wliterals[30]); { p->ice_ping(); diff --git a/csharp/test/Ice/operations/MyDerivedClassAMDI.cs b/csharp/test/Ice/operations/MyDerivedClassAMDI.cs index f7d9f4b267e..d25fe1a15e6 100644 --- a/csharp/test/Ice/operations/MyDerivedClassAMDI.cs +++ b/csharp/test/Ice/operations/MyDerivedClassAMDI.cs @@ -910,6 +910,47 @@ public sealed class MyDerivedClassI : Test.MyDerivedClass Test.su2.value }); } + + public override void opWStringLiterals_async(Test.AMD_MyClass_opWStringLiterals cb, Ice.Current current) + { + cb.ice_response(new string[] + { + Test.s0.value, + Test.s1.value, + Test.s2.value, + Test.s3.value, + Test.s4.value, + Test.s5.value, + Test.s6.value, + Test.s7.value, + Test.s8.value, + Test.s9.value, + Test.s10.value, + + Test.sw0.value, + Test.sw1.value, + Test.sw2.value, + Test.sw3.value, + Test.sw4.value, + Test.sw5.value, + Test.sw6.value, + Test.sw7.value, + Test.sw8.value, + Test.sw9.value, + Test.sw10.value, + + Test.ss0.value, + Test.ss1.value, + Test.ss2.value, + Test.ss3.value, + Test.ss4.value, + Test.ss5.value, + + Test.su0.value, + Test.su1.value, + Test.su2.value + }); + } private Thread_opVoid _opVoidThread; private int _opByteSOnewayCallCount = 0; diff --git a/csharp/test/Ice/operations/MyDerivedClassAMDTieI.cs b/csharp/test/Ice/operations/MyDerivedClassAMDTieI.cs index 984b168ba28..b1efecbbc2b 100644 --- a/csharp/test/Ice/operations/MyDerivedClassAMDTieI.cs +++ b/csharp/test/Ice/operations/MyDerivedClassAMDTieI.cs @@ -888,6 +888,47 @@ public sealed class MyDerivedClassTieI : Test.MyDerivedClassOperations_ Test.su2.value }); } + + public void opWStringLiterals_async(Test.AMD_MyClass_opWStringLiterals cb, Ice.Current current) + { + cb.ice_response(new string[] + { + Test.s0.value, + Test.s1.value, + Test.s2.value, + Test.s3.value, + Test.s4.value, + Test.s5.value, + Test.s6.value, + Test.s7.value, + Test.s8.value, + Test.s9.value, + Test.s10.value, + + Test.sw0.value, + Test.sw1.value, + Test.sw2.value, + Test.sw3.value, + Test.sw4.value, + Test.sw5.value, + Test.sw6.value, + Test.sw7.value, + Test.sw8.value, + Test.sw9.value, + Test.sw10.value, + + Test.ss0.value, + Test.ss1.value, + Test.ss2.value, + Test.ss3.value, + Test.ss4.value, + Test.ss5.value, + + Test.su0.value, + Test.su1.value, + Test.su2.value + }); + } private Thread_opVoid _opVoidThread; private int _opByteSOnewayCallCount = 0; diff --git a/csharp/test/Ice/operations/MyDerivedClassI.cs b/csharp/test/Ice/operations/MyDerivedClassI.cs index 07a182741cb..9832f3ba57e 100644 --- a/csharp/test/Ice/operations/MyDerivedClassI.cs +++ b/csharp/test/Ice/operations/MyDerivedClassI.cs @@ -870,6 +870,11 @@ public sealed class MyDerivedClassI : Test.MyDerivedClass Test.su2.value }; } + + public override string[] opWStringLiterals(Ice.Current current) + { + return opStringLiterals(current); + } private int _opByteSOnewayCallCount = 0; } diff --git a/csharp/test/Ice/operations/MyDerivedClassTieI.cs b/csharp/test/Ice/operations/MyDerivedClassTieI.cs index 7d36de46c69..4ad9d672d48 100644 --- a/csharp/test/Ice/operations/MyDerivedClassTieI.cs +++ b/csharp/test/Ice/operations/MyDerivedClassTieI.cs @@ -846,5 +846,10 @@ public sealed class MyDerivedClassTieI : Test.MyDerivedClassOperations_ }; } + public string[] opWStringLiterals(Ice.Current current) + { + return opStringLiterals(current); + } + private int _opByteSOnewayCallCount = 0; } diff --git a/csharp/test/Ice/operations/Test.ice b/csharp/test/Ice/operations/Test.ice index d085b4b2cd3..d0f62b7483b 100644 --- a/csharp/test/Ice/operations/Test.ice +++ b/csharp/test/Ice/operations/Test.ice @@ -253,6 +253,7 @@ class MyClass ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); StringS opStringLiterals(); + StringS opWStringLiterals(); }; struct MyStruct1 diff --git a/csharp/test/Ice/operations/TestAMD.ice b/csharp/test/Ice/operations/TestAMD.ice index 179834bcd5f..60c1f9144c7 100644 --- a/csharp/test/Ice/operations/TestAMD.ice +++ b/csharp/test/Ice/operations/TestAMD.ice @@ -251,6 +251,7 @@ dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD; ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); StringS opStringLiterals(); + StringS opWStringLiterals(); }; struct MyStruct1 diff --git a/java/test/src/main/java/test/Ice/operations/AMDMyDerivedClassI.java b/java/test/src/main/java/test/Ice/operations/AMDMyDerivedClassI.java index 02b88e5d91a..7a9a61530b7 100644 --- a/java/test/src/main/java/test/Ice/operations/AMDMyDerivedClassI.java +++ b/java/test/src/main/java/test/Ice/operations/AMDMyDerivedClassI.java @@ -929,6 +929,48 @@ public final class AMDMyDerivedClassI extends MyDerivedClass su2.value }); } + + @Override + public void opWStringLiterals_async(AMD_MyClass_opWStringLiterals cb, Ice.Current current) + { + cb.ice_response(new String[] + { + s0.value, + s1.value, + s2.value, + s3.value, + s4.value, + s5.value, + s6.value, + s7.value, + s8.value, + s9.value, + s10.value, + + sw0.value, + sw1.value, + sw2.value, + sw3.value, + sw4.value, + sw5.value, + sw6.value, + sw7.value, + sw8.value, + sw9.value, + sw10.value, + + ss0.value, + ss1.value, + ss2.value, + ss3.value, + ss4.value, + ss5.value, + + su0.value, + su1.value, + su2.value + }); + } private Thread _opVoidThread; private int _opByteSOnewayCallCount = 0; diff --git a/java/test/src/main/java/test/Ice/operations/AMDTieMyDerivedClassI.java b/java/test/src/main/java/test/Ice/operations/AMDTieMyDerivedClassI.java index 1e5ab277b56..8b78ab51efd 100644 --- a/java/test/src/main/java/test/Ice/operations/AMDTieMyDerivedClassI.java +++ b/java/test/src/main/java/test/Ice/operations/AMDTieMyDerivedClassI.java @@ -893,6 +893,48 @@ public final class AMDTieMyDerivedClassI implements _MyDerivedClassOperations su2.value }); } + + @Override + public void opWStringLiterals_async(AMD_MyClass_opWStringLiterals cb, Ice.Current current) + { + cb.ice_response(new String[] + { + s0.value, + s1.value, + s2.value, + s3.value, + s4.value, + s5.value, + s6.value, + s7.value, + s8.value, + s9.value, + s10.value, + + sw0.value, + sw1.value, + sw2.value, + sw3.value, + sw4.value, + sw5.value, + sw6.value, + sw7.value, + sw8.value, + sw9.value, + sw10.value, + + ss0.value, + ss1.value, + ss2.value, + ss3.value, + ss4.value, + ss5.value, + + su0.value, + su1.value, + su2.value + }); + } private Thread _opVoidThread; private int _opByteSOnewayCallCount = 0; diff --git a/java/test/src/main/java/test/Ice/operations/MyDerivedClassI.java b/java/test/src/main/java/test/Ice/operations/MyDerivedClassI.java index 2e7d418a7ea..a0b09d438d3 100644 --- a/java/test/src/main/java/test/Ice/operations/MyDerivedClassI.java +++ b/java/test/src/main/java/test/Ice/operations/MyDerivedClassI.java @@ -875,5 +875,11 @@ public final class MyDerivedClassI extends MyDerivedClass }; } + @Override + public String[] opWStringLiterals(Ice.Current current) + { + return opStringLiterals(current); + } + private int _opByteSOnewayCallCount = 0; } diff --git a/java/test/src/main/java/test/Ice/operations/Test.ice b/java/test/src/main/java/test/Ice/operations/Test.ice index 069faffeb6b..4a99bcae36d 100644 --- a/java/test/src/main/java/test/Ice/operations/Test.ice +++ b/java/test/src/main/java/test/Ice/operations/Test.ice @@ -252,6 +252,7 @@ class MyClass ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); StringS opStringLiterals(); + StringS opWStringLiterals(); }; struct MyStruct1 diff --git a/java/test/src/main/java/test/Ice/operations/TestAMD.ice b/java/test/src/main/java/test/Ice/operations/TestAMD.ice index 19b2eb839b5..3f53e4597f7 100644 --- a/java/test/src/main/java/test/Ice/operations/TestAMD.ice +++ b/java/test/src/main/java/test/Ice/operations/TestAMD.ice @@ -252,6 +252,7 @@ dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD; ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); StringS opStringLiterals(); + StringS opWStringLiterals(); }; struct MyStruct1 diff --git a/java/test/src/main/java/test/Ice/operations/TieMyDerivedClassI.java b/java/test/src/main/java/test/Ice/operations/TieMyDerivedClassI.java index 0e4e6b89cb1..34c55945ed3 100644 --- a/java/test/src/main/java/test/Ice/operations/TieMyDerivedClassI.java +++ b/java/test/src/main/java/test/Ice/operations/TieMyDerivedClassI.java @@ -838,6 +838,12 @@ public final class TieMyDerivedClassI implements _MyDerivedClassOperations su2.value }; } + + @Override + public String[] opWStringLiterals(Ice.Current current) + { + return opStringLiterals(current); + } private int _opByteSOnewayCallCount = 0; } diff --git a/objective-c/test/Ice/operations/OperationsTest.ice b/objective-c/test/Ice/operations/OperationsTest.ice index 0f33cefb761..f64d9f5d5ce 100644 --- a/objective-c/test/Ice/operations/OperationsTest.ice +++ b/objective-c/test/Ice/operations/OperationsTest.ice @@ -277,6 +277,9 @@ class MyClass ByteBoolD opByteBoolD1(ByteBoolD opByteBoolD1); StringS opStringS2(StringS stringS); ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); + + StringS opStringLiterals(); + StringS opWStringLiterals(); // // Operations below are specific to Objective-C @@ -314,4 +317,70 @@ class MyDerivedClass extends MyClass MyStruct1 opMyStruct1(MyStruct1 c); }; + +// +// String literals +// + +const string s0 = "\u005c"; // backslash +const string s1 = "\u0041"; // A +const string s2 = "\u0049\u0063\u0065"; // Ice +const string s3 = "\u004121"; // A21 +const string s4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041 +const string s5 = "\u00FF"; // ÿ +const string s6 = "\u03FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF) +const string s7 = "\u05F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0) +const string s8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000) +const string s9 = "\U0001F34C"; // BANANA (U+1F34C) +const string s10 = "\u0DA7"; // Sinhala Letter Alpapraana Ttayanna + +const string sw0 = "\U0000005c"; // backslash +const string sw1 = "\U00000041"; // A +const string sw2 = "\U00000049\U00000063\U00000065"; // Ice +const string sw3 = "\U0000004121"; // A21 +const string sw4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041 +const string sw5 = "\U000000FF"; // ÿ +const string sw6 = "\U000003FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF) +const string sw7 = "\U000005F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0) +const string sw8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000) +const string sw9 = "\U0001F34C"; // BANANA (U+1F34C) +const string sw10 = "\U00000DA7"; // Sinhala Letter Alpapraana Ttayanna + +/** +\' single quote byte 0x27 in ASCII encoding +\" double quote byte 0x22 in ASCII encoding +\? question mark byte 0x3f in ASCII encoding +\\ backslash byte 0x5c in ASCII encoding +\a audible bell byte 0x07 in ASCII encoding +\b backspace byte 0x08 in ASCII encoding +\f form feed - new page byte 0x0c in ASCII encoding +\n line feed - new line byte 0x0a in ASCII encoding +\r carriage return byte 0x0d in ASCII encoding +\t horizontal tab byte 0x09 in ASCII encoding +\v vertical tab byte 0x0b in ASCII encoding +**/ + +const string ss0 = "\'\"\?\\\a\b\f\n\r\t\v"; +const string ss1 = "\u0027\u0022\u003f\u005c\u0007\u0008\u000c\u000a\u000d\u0009\u000b"; +const string ss2 = "\U00000027\U00000022\U0000003f\U0000005c\U00000007\U00000008\U0000000c\U0000000a\U0000000d\U00000009\U0000000b"; + +const string ss3 = "\\\\U\\u\\"; /* \\U\u\ */ +const string ss4 = "\\\u0041\\"; /* \A\ */ +const string ss5 = "\\u0041\\"; /* \u0041\ */ + +// +// ÿ - Unicode Character 'LATIN SMALL LETTER Y WITH DIAERESIS' (U+00FF) +// Ā - Unicode Character 'LATIN CAPITAL LETTER A WITH MACRON' (U+0100) +// ἀ - Unicode Character 'GREEK SMALL LETTER ALPHA WITH PSILI' (U+1F00) +// 𐆔 - Unicode Character 'ROMAN DIMIDIA SEXTULA SIGN' (U+10194) +// 𐅪 - Unicode Character 'GREEK ACROPHONIC THESPIAN ONE HUNDRED' (U+1016A) +// 𐆘 - Unicode Character 'ROMAN SESTERTIUS SIGN' (U+10198) +// 🍀 - Unicode Character 'FOUR LEAF CLOVER' (U+1F340) +// 🍁 - Unicode Character 'MAPLE LEAF' (U+1F341) +// 🍂 - Unicode Character 'FALLEN LEAF' (U+1F342) +// 🍃 - Unicode Character 'LEAF FLUTTERING IN WIND' (U+1F343) +const string su0 = "ÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; +const string su1 = "\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +const string su2 = "\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; + }; diff --git a/objective-c/test/Ice/operations/TestI.m b/objective-c/test/Ice/operations/TestI.m index 18ce9629512..0eb40c665f3 100644 --- a/objective-c/test/Ice/operations/TestI.m +++ b/objective-c/test/Ice/operations/TestI.m @@ -719,6 +719,51 @@ return p; } +-(TestOperationsStringS *) opStringLiterals:(ICECurrent *)current +{ + TestOperationsStringS *s = [NSArray arrayWithObjects:TestOperationss0, + TestOperationss1, + TestOperationss2, + TestOperationss3, + TestOperationss4, + TestOperationss5, + TestOperationss6, + TestOperationss7, + TestOperationss8, + TestOperationss9, + TestOperationss10, + + TestOperationssw0, + TestOperationssw1, + TestOperationssw2, + TestOperationssw3, + TestOperationssw4, + TestOperationssw5, + TestOperationssw6, + TestOperationssw7, + TestOperationssw8, + TestOperationssw9, + TestOperationssw10, + + TestOperationsss0, + TestOperationsss1, + TestOperationsss2, + TestOperationsss3, + TestOperationsss4, + TestOperationsss5, + + TestOperationssu0, + TestOperationssu1, + TestOperationssu2, + nil]; + return s; +} + +-(TestOperationsStringS *) opWStringLiterals:(ICECurrent *)current +{ + return [self opStringLiterals:current]; +} + -(TestOperationsMyClass1*) opMyClass1:(TestOperationsMyClass1*)p current:(ICECurrent*)current { return p; diff --git a/objective-c/test/Ice/operations/Twoways.m b/objective-c/test/Ice/operations/Twoways.m index ab98727344e..77977e0c243 100644 --- a/objective-c/test/Ice/operations/Twoways.m +++ b/objective-c/test/Ice/operations/Twoways.m @@ -81,6 +81,90 @@ void twoways(id<ICECommunicator> communicator, id<TestOperationsMyClassPrx> p) { { + TestOperationsStringS *literals = [p opStringLiterals]; + + test([TestOperationss0 isEqualToString:[literals objectAtIndex: 0]]); + + + test([TestOperationss0 isEqualToString:@"\\"] && + [TestOperationss0 isEqualToString:TestOperationssw0] && + [TestOperationss0 isEqualToString:[literals objectAtIndex:0]] && + [TestOperationss0 isEqualToString:[literals objectAtIndex:11]]); + + test([TestOperationss1 isEqualToString:@"A"] && + [TestOperationss1 isEqualToString:TestOperationssw1] && + [TestOperationss1 isEqualToString:[literals objectAtIndex:1]] && + [TestOperationss1 isEqualToString:[literals objectAtIndex:12]]); + + test([TestOperationss2 isEqualToString:@"Ice"] && + [TestOperationss2 isEqualToString:TestOperationssw2] && + [TestOperationss2 isEqualToString:[literals objectAtIndex:2]] && + [TestOperationss2 isEqualToString:[literals objectAtIndex:13]]); + + test([TestOperationss3 isEqualToString:@"A21"] && + [TestOperationss3 isEqualToString:TestOperationssw3] && + [TestOperationss3 isEqualToString:[literals objectAtIndex:3]] && + [TestOperationss3 isEqualToString:[literals objectAtIndex:14]]); + + test([TestOperationss4 isEqualToString:@"\\u0041 \\U00000041"] && + [TestOperationss4 isEqualToString:TestOperationssw4] && + [TestOperationss4 isEqualToString:[literals objectAtIndex:4]] && + [TestOperationss4 isEqualToString:[literals objectAtIndex:15]]); + + test([TestOperationss5 isEqualToString:@"ÿ"] && + [TestOperationss5 isEqualToString:TestOperationssw5] && + [TestOperationss5 isEqualToString:[literals objectAtIndex:5]] && + [TestOperationss5 isEqualToString:[literals objectAtIndex:16]]); + + test([TestOperationss6 isEqualToString:@"Ͽ"] && + [TestOperationss6 isEqualToString:TestOperationssw6] && + [TestOperationss6 isEqualToString:[literals objectAtIndex:6]] && + [TestOperationss6 isEqualToString:[literals objectAtIndex:17]]); + + test([TestOperationss7 isEqualToString:@"װ"] && + [TestOperationss7 isEqualToString:TestOperationssw7] && + [TestOperationss7 isEqualToString:[literals objectAtIndex:7]] && + [TestOperationss7 isEqualToString:[literals objectAtIndex:18]]); + + test([TestOperationss8 isEqualToString:@"\U00010000"] && + [TestOperationss8 isEqualToString:TestOperationssw8] && + [TestOperationss8 isEqualToString:[literals objectAtIndex:8]] && + [TestOperationss8 isEqualToString:[literals objectAtIndex:19]]); + + test([TestOperationss9 isEqualToString:@"\U0001F34C"] && + [TestOperationss9 isEqualToString:TestOperationssw9] && + [TestOperationss9 isEqualToString:[literals objectAtIndex:9]] && + [TestOperationss9 isEqualToString:[literals objectAtIndex:20]]); + + test([TestOperationss10 isEqualToString:@"ට"] && + [TestOperationss10 isEqualToString:TestOperationssw10] && + [TestOperationss10 isEqualToString:[literals objectAtIndex:10]] && + [TestOperationss10 isEqualToString:[literals objectAtIndex:21]]); + + test([TestOperationsss0 isEqualToString:@"\'\"\?\\\a\b\f\n\r\t\v"] && + [TestOperationsss0 isEqualToString:TestOperationsss1] && + [TestOperationsss0 isEqualToString:TestOperationsss2] && + [TestOperationsss0 isEqualToString:[literals objectAtIndex:22]] && + [TestOperationsss0 isEqualToString:[literals objectAtIndex:23]] && + [TestOperationsss0 isEqualToString:[literals objectAtIndex:24]]); + + test([TestOperationsss3 isEqualToString:@"\\\\U\\u\\"] && + [TestOperationsss3 isEqualToString:[literals objectAtIndex:25]]); + + test([TestOperationsss4 isEqualToString:@"\\A\\"] && + [TestOperationsss4 isEqualToString:[literals objectAtIndex:26]]); + + test([TestOperationsss5 isEqualToString:@"\\u0041\\"] && + [TestOperationsss5 isEqualToString:[literals objectAtIndex:27]]); + + test([TestOperationssu0 isEqualToString:TestOperationssu1] && + [TestOperationssu0 isEqualToString:TestOperationssu1] && + [TestOperationssu0 isEqualToString:[literals objectAtIndex:28]] && + [TestOperationssu0 isEqualToString:[literals objectAtIndex:29]] && + [TestOperationssu0 isEqualToString:[literals objectAtIndex:30]]); + } + + { [p opVoid]; } diff --git a/python/test/Ice/operations/ServerAMD.py b/python/test/Ice/operations/ServerAMD.py index 3561221335a..63611ff1ed8 100755 --- a/python/test/Ice/operations/ServerAMD.py +++ b/python/test/Ice/operations/ServerAMD.py @@ -409,6 +409,9 @@ class MyDerivedClassI(Test.MyDerivedClass): Test.sw0, Test.sw1, Test.sw2, Test.sw3, Test.sw4, Test.sw5, Test.sw6, Test.sw7, Test.sw8, Test.sw9, Test.sw10, Test.ss0, Test.ss1, Test.ss2, Test.ss3, Test.ss4, Test.ss5, Test.su0, Test.su1, Test.su2]) + + def opWStringLiterals_async(self, cb, current=None): + return self.opStringLiterals_async(cb, current) def run(args, communicator): communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp") diff --git a/python/test/Ice/operations/Test.ice b/python/test/Ice/operations/Test.ice index 7f5ec510834..b0d9f02380e 100644 --- a/python/test/Ice/operations/Test.ice +++ b/python/test/Ice/operations/Test.ice @@ -248,6 +248,7 @@ class MyClass ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); StringS opStringLiterals(); + StringS opWStringLiterals(); }; struct MyStruct1 diff --git a/python/test/Ice/operations/TestAMD.ice b/python/test/Ice/operations/TestAMD.ice index ba567612d60..4bb71e8a3cb 100644 --- a/python/test/Ice/operations/TestAMD.ice +++ b/python/test/Ice/operations/TestAMD.ice @@ -246,6 +246,7 @@ dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD; ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); StringS opStringLiterals(); + StringS opWStringLiterals(); }; struct MyStruct1 diff --git a/python/test/Ice/operations/TestI.py b/python/test/Ice/operations/TestI.py index 6700fbfa26e..449afb523fe 100644 --- a/python/test/Ice/operations/TestI.py +++ b/python/test/Ice/operations/TestI.py @@ -367,5 +367,8 @@ class MyDerivedClassI(Test.MyDerivedClass): Test.sw0, Test.sw1, Test.sw2, Test.sw3, Test.sw4, Test.sw5, Test.sw6, Test.sw7, Test.sw8, Test.sw9, Test.sw10, Test.ss0, Test.ss1, Test.ss2, Test.ss3, Test.ss4, Test.ss5, Test.su0, Test.su1, Test.su2] + + def opWStringLiterals(self, current=None): + return self.opStringLiterals(current)
\ No newline at end of file diff --git a/ruby/src/IceRuby/Slice.cpp b/ruby/src/IceRuby/Slice.cpp index 7f4aac49b25..27ff4d465b0 100644 --- a/ruby/src/IceRuby/Slice.cpp +++ b/ruby/src/IceRuby/Slice.cpp @@ -145,6 +145,10 @@ IceRuby_loadSlice(int argc, VALUE* argv, VALUE self) ostringstream codeStream; IceUtilInternal::Output out(codeStream); out.setUseTab(false); + // + // Ruby magic comment to set the file encoding, it must be first or second line + // + out << "# encoding: utf-8\n"; generate(u, all, checksum, includePaths, out); u->destroy(); |