summaryrefslogtreecommitdiff
path: root/cpp/include/IceUtil/Unicode.h
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2006-01-09 21:32:52 +0000
committerBernard Normier <bernard@zeroc.com>2006-01-09 21:32:52 +0000
commit7ce53a467f83a526d33b39280943814f452a97a8 (patch)
tree178c8ed5427e4798c54933258e37d7897b04cd57 /cpp/include/IceUtil/Unicode.h
parentfile BerkeleyDBRuntime.ism was initially added on branch R3_0_branch. (diff)
downloadice-7ce53a467f83a526d33b39280943814f452a97a8.tar.bz2
ice-7ce53a467f83a526d33b39280943814f452a97a8.tar.xz
ice-7ce53a467f83a526d33b39280943814f452a97a8.zip
Reimplement Unicode.h ; new StringConverter class
Diffstat (limited to 'cpp/include/IceUtil/Unicode.h')
-rw-r--r--cpp/include/IceUtil/Unicode.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/cpp/include/IceUtil/Unicode.h b/cpp/include/IceUtil/Unicode.h
index 366e673b220..8e85c93b49e 100644
--- a/cpp/include/IceUtil/Unicode.h
+++ b/cpp/include/IceUtil/Unicode.h
@@ -82,6 +82,49 @@ ICE_UTIL_API std::wstring stringToWstring(const std::string&);
#endif
+
+//
+// Converts UTF-8 byte-sequences to and from UTF-16 or UTF-32 (with native
+// endianness) depending on sizeof(wchar_t).
+//
+// These are thin wrappers over the UTF8/16/32 converters provided by
+// unicode.org
+//
+//
+// TODO: provide the same support for /Zc:wchar_t as the functions above
+//
+
+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 */
+};
+
+enum ConversionFlags
+{
+ strictConversion = 0,
+ lenientConversion
+};
+
+typedef unsigned char Byte;
+
+ICE_UTIL_API bool
+isLegalUTF8Sequence(const Byte* source, const Byte* end);
+
+ICE_UTIL_API ConversionResult
+convertUTFWstringToUTF8(const wchar_t*& sourceStart, const wchar_t* sourceEnd,
+ Byte*& targetStart, Byte* targetEnd, ConversionFlags flags);
+
+ICE_UTIL_API ConversionResult
+convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* sourceEnd,
+ wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags);
+
+ICE_UTIL_API ConversionResult
+convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* sourceEnd,
+ std::wstring& target, ConversionFlags flags);
+
}
#endif