diff options
Diffstat (limited to 'cpp/src/IceUtil/Unicode.cpp')
-rw-r--r-- | cpp/src/IceUtil/Unicode.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp index 1cff84ab08a..6410cb2b9b5 100644 --- a/cpp/src/IceUtil/Unicode.cpp +++ b/cpp/src/IceUtil/Unicode.cpp @@ -19,27 +19,27 @@ IceUtil::wstringToString(const wstring& str) string result; result.reserve(str.length() * 2); - for (unsigned int i = 0; i < str.length(); ++i) + for(unsigned int i = 0; i < str.length(); ++i) { wchar_t wc; wc = str[i]; - if (wc < 0x80) + if(wc < 0x80) { result += static_cast<char>(wc); } - else if (wc < 0x800) + else if(wc < 0x800) { result += 0xc0 | (wc>>6); result += 0x80 | (wc & 0x3f); } - else if (wc < 0x10000) + else if(wc < 0x10000) { result += 0xe0 | (wc>>12); result += 0x80 | ((wc>>6) & 0x3f); result += 0x80 | (wc & 0x3f); } - else if (wc < 0x10FFFF) + else if(wc < 0x10FFFF) { result += 0xf0 | (wc>>18); result += 0x80 | ((wc>>12) & 0x3f); @@ -62,19 +62,19 @@ IceUtil::stringToWstring(const string& str) result.reserve(str.length()); unsigned int len; - for (unsigned int i = 0; i < str.length(); i += len) + for(unsigned int i = 0; i < str.length(); i += len) { unsigned char c = str[i]; wchar_t wc; int minval; - if (c < 0x80) + if(c < 0x80) { wc = c; len = 1; minval = 0; } - else if (c < 0xc0) // Lead byte must not be 10xxxxxx + else if(c < 0xc0) // Lead byte must not be 10xxxxxx { return result; // Error, not encodable. } @@ -97,14 +97,14 @@ IceUtil::stringToWstring(const string& str) len = 4; minval = 0x10000; } - else if (c < 0xfc) // 111110xx + else if(c < 0xfc) // 111110xx { // Length 5 and 6 is declared invalid in Unicode 3.1 and ISO 10646:2001. wc = c & 3; len = 5; minval = 0x110000; } - else if (c < 0xfe) // 1111110x + else if(c < 0xfe) // 1111110x { // Length 5 and 6 is declared invalid in Unicode 3.1 and ISO 10646:2001. wc = c & 1; @@ -117,11 +117,11 @@ IceUtil::stringToWstring(const string& str) return result; // Error, not encodable. } - if (i + len - 1 < str.length()) + if(i + len - 1 < str.length()) { - for (unsigned int j = 1; j < len; ++j) + for(unsigned int j = 1; j < len; ++j) { - if ((str[i + j] & 0xc0) != 0x80) // All other bytes must be 10xxxxxx + if((str[i + j] & 0xc0) != 0x80) // All other bytes must be 10xxxxxx { return result; // Error, not encodable. } @@ -130,7 +130,7 @@ IceUtil::stringToWstring(const string& str) wc |= str[i + j] & 0x3f; } - if (wc < minval) + if(wc < minval) { return result; // Error, non-shortest form. } |