summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/ConvertUTF.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceUtil/ConvertUTF.h')
-rw-r--r--cpp/src/IceUtil/ConvertUTF.h37
1 files changed, 24 insertions, 13 deletions
diff --git a/cpp/src/IceUtil/ConvertUTF.h b/cpp/src/IceUtil/ConvertUTF.h
index a761ef455b8..b7285b4e0f4 100644
--- a/cpp/src/IceUtil/ConvertUTF.h
+++ b/cpp/src/IceUtil/ConvertUTF.h
@@ -32,9 +32,6 @@
#ifndef ICE_UTIL_CONVERT_UTF_H
#define ICE_UTIL_CONVERT_UTF_H
-#include <IceUtil/Unicode.h>
-
-
/* ---------------------------------------------------------------------
Conversions between UTF32, UTF-16, and UTF-8. Header file.
@@ -94,6 +91,25 @@
------------------------------------------------------------------------ */
+
+namespace IceUtilInternal
+{
+
+enum ConversionFlags
+{
+ strictConversion = 0,
+ lenientConversion
+};
+
+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 */
+};
+
+
/* ---------------------------------------------------------------------
The following 4 definitions are compiler-specific.
The C standard does not guarantee that wchar_t has at least
@@ -102,9 +118,6 @@
bit mask & shift operations.
------------------------------------------------------------------------ */
-namespace IceUtilInternal
-{
-
typedef unsigned int UTF32; /* at least 32 bits */
typedef unsigned short UTF16; /* at least 16 bits */
typedef unsigned char UTF8; /* typically 8 bits */
@@ -120,23 +133,21 @@ typedef bool Boolean; /* 0 or 1 */
ConversionResult ConvertUTF8toUTF16(
const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF16** targetStart, UTF16* targetEnd, IceUtil::ConversionFlags flags);
+ UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF16toUTF8 (
const UTF16** sourceStart, const UTF16* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, IceUtil::ConversionFlags flags);
+ UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF8toUTF32(
const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF32** targetStart, UTF32* targetEnd, IceUtil::ConversionFlags flags);
+ UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF32toUTF8(
const UTF32** sourceStart, const UTF32* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, IceUtil::ConversionFlags flags);
+ UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
-//
-// isLegalUTFSequence is declared in IceUtil/StringConverter.h
-//
+bool isLegalUTF8Sequence(const UTF8* source, const UTF8* end);
/* --------------------------------------------------------------------- */