--- parser3/src/include/pa_charset.h 2008/06/03 12:13:29 1.34 +++ parser3/src/include/pa_charset.h 2009/05/14 11:27:23 1.42 @@ -1,14 +1,14 @@ /** @file 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 (http://paf.design.ru) */ #ifndef PA_CHARSET_H #define PA_CHARSET_H -static const char * const IDENT_CHARSET_H="$Date: 2008/06/03 12:13:29 $"; +static const char * const IDENT_CHARSET_H="$Date: 2009/05/14 11:27:23 $"; #include "pa_exception.h" @@ -16,11 +16,11 @@ static const char * const IDENT_CHARSET_ #include "pa_hash.h" #include "pa_array.h" -// hiding into namespace so to avoid stupid conflict -namespace PCRE { +// pcre.h must be included BEFORE pcre_internal.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 #include "libxml/encoding.h" @@ -32,16 +32,16 @@ namespace PCRE { #define MAX_CHARSET_UNI_CODES 500 -# ifndef XMLCh - typedef unsigned int XMLCh; -# endif -# ifndef XMLByte - typedef unsigned char XMLByte; -# endif +#ifndef XMLCh + typedef unsigned int XMLCh; +#endif +#ifndef XMLByte + typedef unsigned char XMLByte; +#endif // helpers -typedef Hash HashStringString; +typedef HashString HashStringString; /** charset holds name & transcode tables registers libxml transcoders @@ -57,9 +57,8 @@ public: bool isUTF8() const { return fisUTF8; } static String::C transcode(const String::C src, - const Charset& source_transcoder, - const Charset& dest_transcoder - ); + const Charset& source_charset, + const Charset& dest_charset); static String& transcode(const String& src, const Charset& source_transcoder, @@ -77,7 +76,16 @@ public: const Charset& source_transcoder, const Charset& dest_transcoder); - void Charset::store_Char(XMLByte*& outPtr, XMLCh src, XMLByte not_found); + 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 xmlCharEncodingHandler& transcoder(const String::Body NAME); @@ -164,5 +172,8 @@ extern Charset::UTF8CaseTable UTF8CaseTo void change_case_UTF8(const XMLByte* srcData, size_t srcLen, XMLByte* toFill, size_t toFillLen, 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); #endif