diff options
author | Bernard Normier <bernard@zeroc.com> | 2016-06-03 14:11:48 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2016-06-03 14:11:48 -0400 |
commit | 48b141f8f6a8603f6b13a85bde002f6b480832f7 (patch) | |
tree | 41cf4ae281ad96e13216ea208a6579aa442844d3 /cpp/src/IceUtil/Unicode.h | |
parent | Fixed 3.7a2 version in msbuild props files (diff) | |
download | ice-48b141f8f6a8603f6b13a85bde002f6b480832f7.tar.bz2 ice-48b141f8f6a8603f6b13a85bde002f6b480832f7.tar.xz ice-48b141f8f6a8603f6b13a85bde002f6b480832f7.zip |
Refactored string converters and use codecvt_utf8[_utf16] when
available instead of ConvertUTF
Diffstat (limited to 'cpp/src/IceUtil/Unicode.h')
-rw-r--r-- | cpp/src/IceUtil/Unicode.h | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/cpp/src/IceUtil/Unicode.h b/cpp/src/IceUtil/Unicode.h index c061ec51da0..24f97424a52 100644 --- a/cpp/src/IceUtil/Unicode.h +++ b/cpp/src/IceUtil/Unicode.h @@ -11,51 +11,38 @@ #define ICE_UTIL_UNICODE_H #include <IceUtil/Config.h> -#include <IceUtil/StringConverter.h> +#include <vector> namespace IceUtilInternal { // -// Converts UTF-8 byte-sequences to and from UTF-16 or UTF-32 (with native -// endianness) depending on sizeof(wchar_t). +// Convert UTF-8 byte-sequences to and from UTF-16 or UTF-32 (with native endianness) // -// These are thin wrappers over the UTF8/16/32 converters provided by -// unicode.org -// - -enum ConversionResult -{ - conversionOK, /* conversion successful */ - sourceExhausted, /* partial character in source, but hit end */ - targetExhausted, /* insuff. room in target for conversion */ - sourceIllegal /* source sequence is illegal/malformed */ -}; +// These are wrappers for Unicode's ConvertUTF.h/cpp. -ConversionResult +// +// Convert wstring encoded with UTF-16 or UTF-32 to UTF-8. +// Returns false if needs for space and true upon success. +// Throws IllegalConversionException to report error +// +bool convertUTFWstringToUTF8(const wchar_t*& sourceStart, const wchar_t* sourceEnd, - IceUtil::Byte*& targetStart, IceUtil::Byte* targetEnd, IceUtil::ConversionFlags flags); + IceUtil::Byte*& targetStart, IceUtil::Byte* targetEnd); -ConversionResult -convertUTF8ToUTFWstring(const IceUtil::Byte*& sourceStart, const IceUtil::Byte* sourceEnd, - wchar_t*& targetStart, wchar_t* targetEnd, IceUtil::ConversionFlags flags); -ConversionResult +void convertUTF8ToUTFWstring(const IceUtil::Byte*& sourceStart, const IceUtil::Byte* sourceEnd, - std::wstring& target, IceUtil::ConversionFlags flags); - + std::wstring& target); -ICE_API ConversionResult -convertUTF8ToUTF16(const std::vector<unsigned char>&, std::vector<unsigned short>&, - IceUtil::ConversionFlags); +void +convertUTF8ToUTF16(const std::vector<unsigned char>&, std::vector<unsigned short>&); -ICE_API ConversionResult -convertUTF8ToUTF32(const std::vector<unsigned char>&, std::vector<unsigned int>&, - IceUtil::ConversionFlags); +void +convertUTF8ToUTF32(const std::vector<unsigned char>&, std::vector<unsigned int>&); -ICE_API ConversionResult -convertUTF32ToUTF8(const std::vector<unsigned int>&, std::vector<unsigned char>&, - IceUtil::ConversionFlags); +void +convertUTF32ToUTF8(const std::vector<unsigned int>&, std::vector<unsigned char>&); } |