1#ifndef __DCL_CHARSET_H__
2#define __DCL_CHARSET_H__ 20071008
4#ifndef __DCL_CONFIG_H__
13#elif defined(_AIX) || defined(__sun__) || defined(__FreeBSD__)
15#elif defined(__APPLE__)
16 #include <sys/_types/_mbstate_t.h>
17#elif defined(__ANDROID__)
18 #include <bits/mbstate_t.h>
19#elif !defined(__DEFINED_mbstate_t) && defined(__linux__)
20 #include <bits/types/mbstate_t.h>
23#ifndef __DCL_OBJECT_H__
26#ifndef __DCL_EXCEPTION_H__
29#ifndef __DCL_STRING_H__
39#define IS_UTF8(bom) ((bom[0] == '\xef') && (bom[1] == '\xbb') \
40 && (bom[2] == '\xbf'))
41#define IS_UTF16BE(bom) ((bom[0] == '\xfe') && (bom[1] == '\xff'))
42#define IS_UTF16LE(bom) ((bom[0] == '\xff') && (bom[1] == '\xfe'))
43#define IS_UTF16(bom) (IS_UTF16BE(bom) || IS_UTF16LE(bom))
44#define IS_UTF32BE(bom) ((bom[0] == '\x00') && (bom[1] == '\x00') \
45 && (bom[2] == '\xfe') && (bom[3] == '\xff'))
46#define IS_UTF32LE(bom) ((bom[0] == '\xff') && (bom[1] == '\xfe') \
47 && (bom[2] == '\x00') && (bom[3] == '\x00'))
48#define IS_UTF32(bom) (IS_UTF32BE(bom) || IS_UTF32LE(bom))
100 size_t getEncodedLength(
const wchar_t* _wcs,
size_t _wcslen)
103 ByteString encode(
const wchar_t* _wcs,
size_t _wcslen = (
size_t)-1)
106 ByteString encode(
const String& _str)
130 String
decode(
const char* _mbs,
size_t _mbslen = (
size_t)-1)
133 String
decode(
const ByteString& _str)
158 static ByteString encode(
const wchar_t* _wcs,
size_t _wcslen)
165 static ByteString encode(
const String& _str)
168 return UTF8Encoder::encode(_str, _str.length());
174 static size_t maxOutCount(
size_t countOfWchars) {
return countOfWchars * 4 + 3; }
192 bool hasBOM()
const {
return __hasBOM; }
194 static String decode(
const char* _mbs,
size_t _mbslen)
201 static String decode(
const ByteString& _str)
204 return UTF8Decoder::decode(_str, _str.length());
208 static size_t maxOutCount(
size_t _countOfBytes) {
return _countOfBytes; }
229 static size_t maxOutCount(
size_t countOfWchars) {
return countOfWchars * 2 + 1; }
257 bool hasBOM()
const {
return __hasBOM; }
261 bool byteOrderChanged()
const {
return __bigEndian != __defaultBigEndian; }
269 bool __defaultBigEndian;
291 static size_t maxOutCount(
size_t countOfWchars) {
return countOfWchars + 1; }
312 bool hasBOM()
const {
return __hasBOM; }
316 bool byteOrderChanged()
const {
return __bigEndian != __defaultBigEndian; }
324 bool __defaultBigEndian;
333 static ByteString encode(
const wchar_t* _wcs,
size_t _wcslen)
340 static ByteString encode(
const String& _str)
343 return AsciiEncoder::encode(_str, _str.length());
360 static String
decode(
const char* _mbs,
size_t _mbslen = (
size_t)-1);
383 static String
decode(
const char* _mbs,
size_t _nmbs = (
size_t)-1);
393 virtual void reset();
403 static ByteString
encode(
const wchar_t* _wcs,
size_t _wcslen)
410 static ByteString
encode(
const String& _str)
417 virtual int toMultiByte(
ucs4_t _uc,
byte_t* _mbs,
size_t _mbslen);
428 virtual void reset();
438 static String decode(
const char* _mbs,
size_t _nmbs = (
size_t)-1)
445 static String decode(
const ByteString& _str)
448 return LocaleDecoder::decode(_str, _str.length());
__DCL_BEGIN_NAMESPACE typedef uint32_t ucs4_t
#define __ORDER_BIG_ENDIAN__
#define __ORDER_LITTLE_ENDIAN__
#define DECLARE_CLASSINFO(class_name)
static String decode(const char *_mbs, size_t _mbslen=(size_t) -1)
virtual int toWideChar(const byte_t *_mbs, size_t _mbslen, ucs4_t *_uc)
virtual int toMultiByte(ucs4_t _uc, byte_t *_mbs, size_t _mbslen)
size_t getDecodedLength(const char *_mbs, size_t _mbslen) __DCL_THROWS1(CharsetConvertException *)
virtual int toWideChar(const byte_t *_mbs, size_t _mbslen, ucs4_t *_uc)=0
virtual int decode(const byte_t *_in, size_t &_inCount, wchar_t *_out, size_t &_outCount)
virtual int toMultiByte(ucs4_t _uc, byte_t *_mbs, size_t _mbslen)=0
virtual String toString() const
Exception(Exception *_cause=NULL)
virtual int toWideChar(const byte_t *_mbs, size_t _mbslen, ucs4_t *_uc)
static String decode(const char *_mbs, size_t _nmbs=(size_t) -1)
virtual int toMultiByte(ucs4_t _uc, byte_t *_mbs, size_t _mbslen)
virtual int toWideChar(const byte_t *_mbs, size_t _mbslen, ucs4_t *_uc)
static ByteString encode(const wchar_t *_wcs, size_t _wcslen) __DCL_THROWS1(CharsetConvertException *)
virtual int encode(const wchar_t *_in, size_t &_inCount, byte_t *_out, size_t &_outCount)
static ByteString encode(const String &_str) __DCL_THROWS1(CharsetConvertException *)
virtual int toWideChar(const byte_t *_mbs, size_t _mbslen, ucs4_t *_uc)
virtual int toMultiByte(ucs4_t _uc, byte_t *_mbs, size_t _mbslen)
virtual int toWideChar(const byte_t *_mbs, size_t _mbslen, ucs4_t *_uc)
virtual int toMultiByte(ucs4_t _uc, byte_t *_mbs, size_t _mbslen)
virtual int toWideChar(const byte_t *_mbs, size_t _mbslen, ucs4_t *_uc)
virtual int toMultiByte(ucs4_t _uc, byte_t *_mbs, size_t _mbslen)