diff options
author | Bernard Normier <bernard@zeroc.com> | 2014-05-16 12:38:47 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2014-05-16 12:38:47 -0400 |
commit | dd32886233aabd25d0c82a156327ad8c48a0203b (patch) | |
tree | 4d464de5b1fe1f5118535be8e02981812013a75d /cpp/src/IceUtil/Unicode.h | |
parent | New header for backwards compat with Ice 3.5 (diff) | |
download | ice-dd32886233aabd25d0c82a156327ad8c48a0203b.tar.bz2 ice-dd32886233aabd25d0c82a156327ad8c48a0203b.tar.xz ice-dd32886233aabd25d0c82a156327ad8c48a0203b.zip |
Forgot Unicode.h
Diffstat (limited to 'cpp/src/IceUtil/Unicode.h')
-rw-r--r-- | cpp/src/IceUtil/Unicode.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/cpp/src/IceUtil/Unicode.h b/cpp/src/IceUtil/Unicode.h new file mode 100644 index 00000000000..7108467fc16 --- /dev/null +++ b/cpp/src/IceUtil/Unicode.h @@ -0,0 +1,49 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICE_UTIL_UNICODE_H +#define ICE_UTIL_UNICODE_H + +#include <IceUtil/Config.h> +#include <IceUtil/StringConverter.h> + +namespace IceUtilInternal +{ + +// +// 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 +// + +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 */ +}; + +ConversionResult +convertUTFWstringToUTF8(const wchar_t*& sourceStart, const wchar_t* sourceEnd, + IceUtil::Byte*& targetStart, IceUtil::Byte* targetEnd, IceUtil::ConversionFlags flags); + +ConversionResult +convertUTF8ToUTFWstring(const IceUtil::Byte*& sourceStart, const IceUtil::Byte* sourceEnd, + wchar_t*& targetStart, wchar_t* targetEnd, IceUtil::ConversionFlags flags); + +ConversionResult +convertUTF8ToUTFWstring(const IceUtil::Byte*& sourceStart, const IceUtil::Byte* sourceEnd, + std::wstring& target, IceUtil::ConversionFlags flags); + +} + +#endif |