diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-12-21 11:12:14 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-12-21 11:12:14 -0500 |
commit | 08ec7524df324e627bbb8d93c509f0d90badbe3b (patch) | |
tree | a640ae99a5e35b210352150feef4f71832b265c5 /cpp/src/IceUtil/ConvertUTF.cpp | |
parent | Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice (diff) | |
download | ice-08ec7524df324e627bbb8d93c509f0d90badbe3b.tar.bz2 ice-08ec7524df324e627bbb8d93c509f0d90badbe3b.tar.xz ice-08ec7524df324e627bbb8d93c509f0d90badbe3b.zip |
IceUtil cleanup (first commit)
Diffstat (limited to 'cpp/src/IceUtil/ConvertUTF.cpp')
-rwxr-xr-x | cpp/src/IceUtil/ConvertUTF.cpp | 67 |
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; + } + } +} + +} |