1#ifndef __DCL_CHARSET_H__
2#define __DCL_CHARSET_H__ 20071008
4#ifndef __DCL_CONFIG_H__
13#elif defined(_AIX) || defined(__sun__)
15#elif defined(__APPLE__)
16 #include <sys/_types/_mbstate_t.h>
18 #include <bits/types/mbstate_t.h>
21#ifndef __DCL_OBJECT_H__
24#ifndef __DCL_EXCEPTION_H__
27#ifndef __DCL_STRING_H__
37#define IS_UTF8(bom) ((bom[0] == '\xef') && (bom[1] == '\xbb') \
38 && (bom[2] == '\xbf'))
39#define IS_UTF16BE(bom) ((bom[0] == '\xfe') && (bom[1] == '\xff'))
40#define IS_UTF16LE(bom) ((bom[0] == '\xff') && (bom[1] == '\xfe'))
41#define IS_UTF16(bom) (IS_UTF16BE(bom) || IS_UTF16LE(bom))
42#define IS_UTF32BE(bom) ((bom[0] == '\x00') && (bom[1] == '\x00') \
43 && (bom[2] == '\xfe') && (bom[3] == '\xff'))
44#define IS_UTF32LE(bom) ((bom[0] == '\xff') && (bom[1] == '\xfe') \
45 && (bom[2] == '\x00') && (bom[3] == '\x00'))
46#define IS_UTF32(bom) (IS_UTF32BE(bom) || IS_UTF32LE(bom))
98 size_t getEncodedLength(
const wchar_t* _wcs,
size_t _wcslen)
101 ByteString encode(
const wchar_t* _wcs,
size_t _wcslen = (
size_t)-1)
104 ByteString encode(
const String& _str)
128 String
decode(
const char* _mbs,
size_t _mbslen = (
size_t)-1)
131 String
decode(
const ByteString& _str)
156 static ByteString encode(
const wchar_t* _wcs,
size_t _wcslen)
163 static ByteString encode(
const String& _str)
166 return UTF8Encoder::encode(_str, _str.length());
172 static size_t maxOutCount(
size_t countOfWchars) {
return countOfWchars * 4 + 3; }
190 bool hasBOM()
const {
return __hasBOM; }
192 static String decode(
const char* _mbs,
size_t _mbslen)
199 static String decode(
const ByteString& _str)
202 return UTF8Decoder::decode(_str, _str.length());
206 static size_t maxOutCount(
size_t _countOfBytes) {
return _countOfBytes; }
227 static size_t maxOutCount(
size_t countOfWchars) {
return countOfWchars * 2 + 1; }
255 bool hasBOM()
const {
return __hasBOM; }
259 bool byteOrderChanged()
const {
return __bigEndian != __defaultBigEndian; }
267 bool __defaultBigEndian;
289 static size_t maxOutCount(
size_t countOfWchars) {
return countOfWchars + 1; }
310 bool hasBOM()
const {
return __hasBOM; }
314 bool byteOrderChanged()
const {
return __bigEndian != __defaultBigEndian; }
322 bool __defaultBigEndian;
331 static ByteString encode(
const wchar_t* _wcs,
size_t _wcslen)
338 static ByteString encode(
const String& _str)
341 return AsciiEncoder::encode(_str, _str.length());
358 static String
decode(
const char* _mbs,
size_t _mbslen = (
size_t)-1);
381 static String
decode(
const char* _mbs,
size_t _nmbs = (
size_t)-1);
391 virtual void reset();
401 static ByteString
encode(
const wchar_t* _wcs,
size_t _wcslen)
408 static ByteString
encode(
const String& _str)
415 virtual int toMultiByte(
ucs4_t _uc,
byte_t* _mbs,
size_t _mbslen);
426 virtual void reset();
436 static String decode(
const char* _mbs,
size_t _nmbs = (
size_t)-1)
443 static String decode(
const ByteString& _str)
446 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)