--- parser3/src/include/pa_charset.h 2009/11/06 05:01:24 1.44 +++ parser3/src/include/pa_charset.h 2012/06/09 12:13:50 1.49 @@ -1,14 +1,14 @@ /** @file Parser: Charset connection decl. - Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2012 Art. Lebedev Studio (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: 2009/11/06 05:01:24 $"; +#define IDENT_PA_CHARSET_H "$Id: pa_charset.h,v 1.49 2012/06/09 12:13:50 moko Exp $" #include "pa_exception.h" @@ -19,7 +19,6 @@ static const char * const IDENT_CHARSET_ // pcre.h must be included BEFORE pcre_internal.h #include "pcre.h" // have to call config.h for using pcre_internal.h as well -#include "../lib/pcre/config.h" #include "pcre_internal.h" #ifdef XML @@ -78,13 +77,18 @@ public: 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); + static String::C escape_JSON(const String::C src, + const Charset& source_charset); + static String::Body escape_JSON(const String::Body src, + const Charset& source_charset); + static String& escape_JSON(const String& src, + const Charset& source_charset); + void store_Char(XMLByte*& outPtr, XMLCh src, XMLByte not_found); #ifdef XML @@ -135,12 +139,24 @@ private: bool fisUTF8; Tables tables; + static size_t calc_escaped_length_UTF8(XMLByte* src, size_t src_length); + static size_t calc_escaped_length(const XMLByte* src, size_t src_length, const Charset::Tables& tables); + static size_t calc_escaped_length(const String::C src, const Charset& source_charset); + static size_t escape_UTF8(const XMLByte* src, size_t src_length, XMLByte* dest); + static size_t escape(const XMLByte* src, size_t src_length, XMLByte* dest, const Charset::Tables& tables); + + static size_t calc_JSON_escaped_length_UTF8(XMLByte* src, size_t src_length); + static size_t calc_JSON_escaped_length(const XMLByte* src, size_t src_length, const Charset::Tables& tables); + static size_t calc_JSON_escaped_length(const String::C src, const Charset& source_charset); + static size_t escape_JSON_UTF8(const XMLByte* src, size_t src_length, XMLByte* dest); + static size_t escape_JSON(const XMLByte* src, size_t src_length, XMLByte* dest, const Charset::Tables& tables); + #ifdef XML private: void addEncoding(char* name_cstr); void initTranscoder(const String::Body name, const char* name_cstr); - + public: /// converts xmlChar* null-terminated string to char* String::C transcode_cstr(const xmlChar* s);