1#ifndef __DCL_CHARSET_H__
2#define __DCL_CHARSET_H__ 20071008
4#ifndef __DCL_CONFIG_H__
14 #include <bits/types/mbstate_t.h>
17#ifndef __DCL_OBJECT_H__
20#ifndef __DCL_EXCEPTION_H__
23#ifndef __DCL_STRING_H__
33#define IS_UTF8(bom) ((bom[0] == 0xEF) && (bom[1] == 0xBB) && (bom[2] == 0xBF))
34#define IS_UTF16BE(bom) ((bom[0] == 0xFE) && (bom[1] == 0xFF))
35#define IS_UTF16LE(bom) ((bom[0] == 0xFF) && (bom[1] == 0xFE))
36#define IS_UTF16(bom) (IS_UTF16BE(bom) || IS_UTF16LE(bom))
37#define IS_UTF32BE(bom) ((bom[0] == 0x00) && (bom[1] == 0x00) \
38 && (bom[2] == 0xFE) && (bom[3] == 0xFF))
39#define IS_UTF32LE(bom) ((bom[0] == 0xFF) && (bom[1] == 0xFE) \
40 && (bom[2] == 0x00) && (bom[3] == 0x00))
41#define IS_UTF32(bom) (IS_UTF32BE(bom) || IS_UTF32LE(bom))
92 size_t getEncodedLength(
const wchar_t* _wcs,
size_t _wcslen)
95 ByteString encode(
const wchar_t* _wcs,
size_t _wcslen = (
size_t)-1)
98 ByteString encode(
const String& _str)
121 String
decode(
const char* _mbs,
size_t _mbslen = (
size_t)-1)
124 String
decode(
const ByteString& _str)
148 static ByteString encode(
const wchar_t* _wcs,
size_t _wcslen)
155 static ByteString encode(
const String& _str)
158 return UTF8Encoder::encode(_str, _str.length());
164 static size_t maxOutCount(
size_t countOfWchars) {
return countOfWchars * 4 + 3; }
180 bool hasBOM()
const {
return __hasBOM; }
182 static String decode(
const char* _mbs,
size_t _mbslen)
189 static String decode(
const ByteString& _str)
192 return UTF8Decoder::decode(_str, _str.length());
196 static size_t maxOutCount(
size_t _countOfBytes) {
return _countOfBytes; }
216 static size_t maxOutCount(
size_t countOfWchars) {
return countOfWchars * 2 + 1; }
242 bool hasBOM()
const {
return __hasBOM; }
244 bool byteOrderChanged()
const {
return __bigEndian != __defaultBigEndian; }
252 bool __defaultBigEndian;
273 static size_t maxOutCount(
size_t countOfWchars) {
return countOfWchars + 1; }
292 bool hasBOM()
const {
return __hasBOM; }
294 bool byteOrderChanged()
const {
return __bigEndian != __defaultBigEndian; }
302 bool __defaultBigEndian;
311 static ByteString encode(
const wchar_t* _wcs,
size_t _wcslen)
318 static ByteString encode(
const String& _str)
321 return AsciiEncoder::encode(_str, _str.length());
338 static String
decode(
const char* _mbs,
size_t _mbslen = (
size_t)-1);
361 static String
decode(
const char* _mbs,
size_t _nmbs = (
size_t)-1);
371 virtual void reset();
381 static ByteString
encode(
const wchar_t* _wcs,
size_t _wcslen)
388 static ByteString
encode(
const String& _str)
395 virtual int toMultiByte(
ucs4_t _uc,
byte_t* _mbs,
size_t _mbslen);
406 virtual void reset();
416 static String decode(
const char* _mbs,
size_t _nmbs = (
size_t)-1)
423 static String decode(
const ByteString& _str)
426 return LocaleDecoder::decode(_str, _str.length());
__DCL_BEGIN_NAMESPACE typedef uint32_t ucs4_t
#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)