summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/ConvertUTF.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceUtil/ConvertUTF.cpp')
-rwxr-xr-xcpp/src/IceUtil/ConvertUTF.cpp67
1 files changed, 38 insertions, 29 deletions
diff --git a/cpp/src/IceUtil/ConvertUTF.cpp b/cpp/src/IceUtil/ConvertUTF.cpp
index f44aea0f0b5..bf7aafec29a 100755
--- a/cpp/src/IceUtil/ConvertUTF.cpp
+++ b/cpp/src/IceUtil/ConvertUTF.cpp
@@ -55,7 +55,9 @@
#include <stdio.h>
#endif
-namespace IceUtil
+using namespace IceUtil;
+
+namespace IceUtilInternal
{
static const int halfShift = 10; /* used for shifting by 10 bits */
@@ -228,34 +230,6 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) {
/* --------------------------------------------------------------------- */
-/*
- * Exported function to return whether a UTF-8 sequence is legal or not.
- * This is not used here; it's just exported.
- */
-Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
- if(source == sourceEnd) {
- return true;
- }
- while(true) {
- int length = trailingBytesForUTF8[*source]+1;
- // Is buffer big enough to contain character?
- if (source+length > sourceEnd) {
- return false;
- }
- // Is character legal UTF8?
- if(!isLegalUTF8(source, length)) {
- return false;
- }
- // Are we at end of buffer?
- source += length;
- if(source == sourceEnd) {
- return true;
- }
- }
-}
-
-/* --------------------------------------------------------------------- */
-
ConversionResult ConvertUTF8toUTF16 (
const UTF8** sourceStart, const UTF8* sourceEnd,
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
@@ -461,3 +435,38 @@ ConversionResult ConvertUTF8toUTF32 (
--------------------------------------------------------------------- */
}
+
+namespace IceUtil
+{
+
+using namespace IceUtilInternal;
+
+/* --------------------------------------------------------------------- */
+
+/*
+ * Exported function to return whether a UTF-8 sequence is legal or not.
+ * This is not used here; it's just exported.
+ */
+Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
+ if(source == sourceEnd) {
+ return true;
+ }
+ while(true) {
+ int length = trailingBytesForUTF8[*source]+1;
+ // Is buffer big enough to contain character?
+ if (source+length > sourceEnd) {
+ return false;
+ }
+ // Is character legal UTF8?
+ if(!isLegalUTF8(source, length)) {
+ return false;
+ }
+ // Are we at end of buffer?
+ source += length;
+ if(source == sourceEnd) {
+ return true;
+ }
+ }
+}
+
+}