diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 46 | ||||
-rw-r--r-- | cpp/src/IceUtil/Unicode.cpp | 10 |
2 files changed, 30 insertions, 26 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 4ca75897a87..9d2bc9bf314 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -95,7 +95,7 @@ IceInternal::BasicStream::endWriteEncaps() } Int sz = b.size() - start; const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + start - sizeof(Int)); #else copy(p, p + sizeof(Int), b.begin() + start - sizeof(Int)); @@ -218,7 +218,7 @@ IceInternal::BasicStream::write(const vector<Byte>& v) Int sz = v.size(); resize(pos + sizeof(Int) + sz); const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + pos); #else copy(p, p + sizeof(Int), b.begin() + pos); @@ -258,7 +258,7 @@ IceInternal::BasicStream::write(const vector<bool>& v) Int sz = v.size(); resize(pos + sizeof(Int) + sz); const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + pos); #else copy(p, p + sizeof(Int), b.begin() + pos); @@ -297,7 +297,7 @@ IceInternal::BasicStream::write(Short v) int pos = b.size(); resize(pos + sizeof(Short)); const Byte* p = reinterpret_cast<const Byte*>(&v); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Short), b.begin() + pos); #else copy(p, p + sizeof(Short), b.begin() + pos); @@ -311,7 +311,7 @@ IceInternal::BasicStream::write(const vector<Short>& v) Int sz = v.size(); resize(pos + sizeof(Int) + sz * sizeof(Short)); const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + pos); pos += sizeof(Int); p = reinterpret_cast<const Byte*>(v.begin()); @@ -337,7 +337,7 @@ IceInternal::BasicStream::read(Short& v) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(begin, i, reinterpret_cast<Byte*>(&v)); #else copy(begin, i, reinterpret_cast<Byte*>(&v)); @@ -356,7 +356,7 @@ IceInternal::BasicStream::read(vector<Short>& v) throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN for (int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Short), reinterpret_cast<Byte*>(&v[j])); @@ -373,7 +373,7 @@ IceInternal::BasicStream::write(Int v) int pos = b.size(); resize(pos + sizeof(Int)); const Byte* p = reinterpret_cast<const Byte*>(&v); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + pos); #else copy(p, p + sizeof(Int), b.begin() + pos); @@ -387,7 +387,7 @@ IceInternal::BasicStream::write(const vector<Int>& v) Int sz = v.size(); resize(pos + sizeof(Int) + sz * sizeof(Int)); const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + pos); pos += sizeof(Int); p = reinterpret_cast<const Byte*>(v.begin()); @@ -413,7 +413,7 @@ IceInternal::BasicStream::read(Int& v) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(begin, i, reinterpret_cast<Byte*>(&v)); #else copy(begin, i, reinterpret_cast<Byte*>(&v)); @@ -432,7 +432,7 @@ IceInternal::BasicStream::read(vector<Int>& v) throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN for (int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Int), reinterpret_cast<Byte*>(&v[j])); @@ -449,7 +449,7 @@ IceInternal::BasicStream::write(Long v) int pos = b.size(); resize(pos + sizeof(Long)); const Byte* p = reinterpret_cast<const Byte*>(&v); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Long), b.begin() + pos); #else copy(p, p + sizeof(Long), b.begin() + pos); @@ -463,7 +463,7 @@ IceInternal::BasicStream::write(const vector<Long>& v) Int sz = v.size(); resize(pos + sizeof(Int) + sz * sizeof(Long)); const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + pos); pos += sizeof(Int); p = reinterpret_cast<const Byte*>(v.begin()); @@ -489,7 +489,7 @@ IceInternal::BasicStream::read(Long& v) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(begin, i, reinterpret_cast<Byte*>(&v)); #else copy(begin, i, reinterpret_cast<Byte*>(&v)); @@ -508,7 +508,7 @@ IceInternal::BasicStream::read(vector<Long>& v) throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN for (int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Long), reinterpret_cast<Byte*>(&v[j])); @@ -525,7 +525,7 @@ IceInternal::BasicStream::write(Float v) int pos = b.size(); resize(pos + sizeof(Float)); const Byte* p = reinterpret_cast<const Byte*>(&v); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Float), b.begin() + pos); #else copy(p, p + sizeof(Float), b.begin() + pos); @@ -539,7 +539,7 @@ IceInternal::BasicStream::write(const vector<Float>& v) Int sz = v.size(); resize(pos + sizeof(Int) + sz * sizeof(Float)); const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + pos); pos += sizeof(Int); p = reinterpret_cast<const Byte*>(v.begin()); @@ -565,7 +565,7 @@ IceInternal::BasicStream::read(Float& v) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(begin, i, reinterpret_cast<Byte*>(&v)); #else copy(begin, i, reinterpret_cast<Byte*>(&v)); @@ -584,7 +584,7 @@ IceInternal::BasicStream::read(vector<Float>& v) throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN for (int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Float), reinterpret_cast<Byte*>(&v[j])); @@ -601,7 +601,7 @@ IceInternal::BasicStream::write(Double v) int pos = b.size(); resize(pos + sizeof(Double)); const Byte* p = reinterpret_cast<const Byte*>(&v); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Double), b.begin() + pos); #else copy(p, p + sizeof(Double), b.begin() + pos); @@ -615,7 +615,7 @@ IceInternal::BasicStream::write(const vector<Double>& v) Int sz = v.size(); resize(pos + sizeof(Int) + sz * sizeof(Double)); const Byte* p = reinterpret_cast<const Byte*>(&sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(p, p + sizeof(Int), b.begin() + pos); pos += sizeof(Int); p = reinterpret_cast<const Byte*>(v.begin()); @@ -641,7 +641,7 @@ IceInternal::BasicStream::read(Double& v) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN reverse_copy(begin, i, reinterpret_cast<Byte*>(&v)); #else copy(begin, i, reinterpret_cast<Byte*>(&v)); @@ -660,7 +660,7 @@ IceInternal::BasicStream::read(vector<Double>& v) throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); -#ifdef ICE_BIGENDIAN +#ifdef ICE_UTIL_BIGENDIAN for (int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Double), reinterpret_cast<Byte*>(&v[j])); diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp index cf996046645..3850193b76a 100644 --- a/cpp/src/IceUtil/Unicode.cpp +++ b/cpp/src/IceUtil/Unicode.cpp @@ -9,6 +9,7 @@ // ********************************************************************** #include <IceUtil/Unicode.h> +#include <algorithm> using namespace std; @@ -20,8 +21,9 @@ IceUtil::wstringToString(const wstring& str) for (unsigned int i = 0; i < str.length(); ++i) { - wchar_t wc = str[i]; - + wchar_t wc; + wc = str[i]; + if (wc < 0x80) { result += static_cast<char>(wc); @@ -110,7 +112,7 @@ IceUtil::stringToWstring(const string& str) if (i + len - 1 < str.length()) { - for (unsigned int j = 1; j < len - 1; ++j) + for (unsigned int j = 1; j < len; ++j) { if ((str[i + j] & 0xc0) != 0x80) // All other bytes must be 10xxxxxx { @@ -120,6 +122,8 @@ IceUtil::stringToWstring(const string& str) wc <<= 6; wc |= str[i + j] & 0x3f; } + + result += wc; } else { |