|
|
| version 1.32, 2005/12/16 10:15:12 | version 1.43, 2009/10/03 02:18:04 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: Charset connection decl. | Parser: Charset connection decl. |
| Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 16 static const char * const IDENT_CHARSET_ | Line 16 static const char * const IDENT_CHARSET_ |
| #include "pa_hash.h" | #include "pa_hash.h" |
| #include "pa_array.h" | #include "pa_array.h" |
| // hiding into namespace so to avoid stupid conflict | // pcre.h must be included BEFORE pcre_internal.h |
| namespace PCRE { | |
| #include "pcre.h" | #include "pcre.h" |
| # include "internal.h" | // have to call config.h for using pcre_internal.h as well |
| }; | #include "../lib/pcre/config.h" |
| #include "pcre_internal.h" | |
| #ifdef XML | #ifdef XML |
| #include "libxml/encoding.h" | #include "libxml/encoding.h" |
| Line 32 namespace PCRE { | Line 32 namespace PCRE { |
| #define MAX_CHARSET_UNI_CODES 500 | #define MAX_CHARSET_UNI_CODES 500 |
| # ifndef XMLCh | #ifndef XMLCh |
| typedef unsigned int XMLCh; | typedef unsigned int XMLCh; |
| # endif | #endif |
| # ifndef XMLByte | #ifndef XMLByte |
| typedef unsigned char XMLByte; | typedef unsigned char XMLByte; |
| # endif | #endif |
| // helpers | // helpers |
| typedef Hash<const String::Body, String::Body> HashStringString; | typedef HashString<String::Body> HashStringString; |
| /** charset holds name & transcode tables | /** charset holds name & transcode tables |
| registers libxml transcoders | registers libxml transcoders |
| Line 57 public: | Line 57 public: |
| bool isUTF8() const { return fisUTF8; } | bool isUTF8() const { return fisUTF8; } |
| static String::C transcode(const String::C src, | static String::C transcode(const String::C src, |
| const Charset& source_transcoder, | const Charset& source_charset, |
| const Charset& dest_transcoder | const Charset& dest_charset); |
| ); | |
| static String& transcode(const String& src, | static String& transcode(const String& src, |
| const Charset& source_transcoder, | const Charset& source_transcoder, |
| Line 77 public: | Line 76 public: |
| const Charset& source_transcoder, | const Charset& source_transcoder, |
| const Charset& dest_transcoder); | const Charset& dest_transcoder); |
| static String::C escape(const String::C src, | |
| const Charset& source_charset); | |
| static String::Body escape(const String::Body src, | |
| const Charset& source_charset); | |
| static String& escape(const String& src, | |
| const Charset& source_charset); | |
| void store_Char(XMLByte*& outPtr, XMLCh src, XMLByte not_found); | |
| #ifdef XML | #ifdef XML |
| xmlCharEncodingHandler& transcoder(const String::Body NAME); | xmlCharEncodingHandler& transcoder(const String::Body NAME); |
| #endif | #endif |
| Line 160 private: | Line 170 private: |
| extern Charset::UTF8CaseTable UTF8CaseToUpper; | extern Charset::UTF8CaseTable UTF8CaseToUpper; |
| extern Charset::UTF8CaseTable UTF8CaseToLower; | extern Charset::UTF8CaseTable UTF8CaseToLower; |
| void change_case_UTF8(const XMLByte* srcData, size_t srcLen, | void change_case_UTF8(const XMLByte* srcData, size_t srcLen, |
| XMLByte* toFill, size_t toFillLen, | XMLByte* toFill, size_t toFillLen, |
| const Charset::UTF8CaseTable& table); | const Charset::UTF8CaseTable& table); |
| size_t getUTF8BytePos(const XMLByte* srcBegin, const XMLByte* srcEnd, size_t charPos/*position in characters*/); | |
| size_t getUTF8CharPos(const XMLByte* srcBegin, const XMLByte* srcEnd, size_t bytePos/*position in bytes*/); | |
| size_t lengthUTF8(const XMLByte* srcBegin, const XMLByte* srcEnd); | |
| class UTF8_string_iterator { | |
| public: | |
| UTF8_string_iterator(const String& astring): fsrcPtr((XMLByte*)astring.cstr()), fsrcEnd(fsrcPtr + astring.length()) {} | |
| UTF8_string_iterator(XMLByte* asrcPtr, size_t length): fsrcPtr(asrcPtr), fsrcEnd(fsrcPtr + length) {} | |
| bool has_next(); | |
| XMLCh next() { return fUTF8Char; } | |
| XMLByte getFirstByte(){ return ffirstByte; } | |
| size_t getCharSize(){ return fcharSize; } | |
| private: | |
| const XMLByte* fsrcPtr; | |
| const XMLByte* fsrcEnd; | |
| size_t fcharSize; | |
| XMLByte ffirstByte; | |
| XMLCh fUTF8Char; | |
| }; | |
| #endif | #endif |