|
|
| version 1.45, 2010/08/27 02:53:34 | version 1.57, 2023/09/26 20:49:06 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: Charset connection decl. | Parser: Charset connection decl. |
| Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| #ifndef PA_CHARSET_H | #ifndef PA_CHARSET_H |
| #define PA_CHARSET_H | #define PA_CHARSET_H |
| static const char * const IDENT_CHARSET_H="$Date$"; | #define IDENT_PA_CHARSET_H "$Id$" |
| #include "pa_exception.h" | #include "pa_exception.h" |
| 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" |
| // pcre.h must be included BEFORE pcre_internal.h | |
| #include "pcre.h" | #include "pcre.h" |
| // have to call config.h for using pcre_internal.h as well | // we are using some pcre_internal.h stuff as well |
| #include "../lib/pcre/config.h" | #include "../lib/pcre/pa_pcre_internal.h" |
| #include "pcre_internal.h" | |
| #ifdef XML | #ifdef XML |
| #include "libxml/encoding.h" | #include "libxml/encoding.h" |
| Line 56 public: | Line 54 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_charset, const Charset& dest_charset); |
| const Charset& source_charset, | static String::Body transcode(const String::Body src, const Charset& source_transcoder, const Charset& dest_transcoder); |
| const Charset& dest_charset); | static String& transcode(const String& src, const Charset& source_transcoder, const Charset& dest_transcoder); |
| static void transcode(ArrayString& src, const Charset& source_transcoder, const Charset& dest_transcoder); | |
| static String& transcode(const String& src, | static void transcode(HashStringString& src, const Charset& source_transcoder, const Charset& dest_transcoder); |
| const Charset& source_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::Body transcode(const String::Body src, | static String& escape(const String& src, const Charset& source_charset); |
| const Charset& source_transcoder, | |
| const Charset& dest_transcoder); | 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 void transcode(ArrayString& src, | static String& escape_JSON(const String& src, const Charset& source_charset); |
| const Charset& source_transcoder, | |
| const Charset& dest_transcoder); | |
| static void transcode(HashStringString& src, | |
| const Charset& source_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); | |
| 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); | void store_Char(XMLByte*& outPtr, XMLCh src, XMLByte not_found); |
| Line 140 private: | Line 118 private: |
| bool fisUTF8; | bool fisUTF8; |
| Tables tables; | Tables tables; |
| #ifdef XML | |
| private: | |
| void addEncoding(char* name_cstr); | |
| void initTranscoder(const String::Body name, const char* name_cstr); | |
| static size_t calc_escaped_length_UTF8(XMLByte* src, size_t src_length); | static size_t calc_escaped_length_UTF8(XMLByte* src, size_t src_length); |
| static size_t calc_escaped_length(XMLByte* src, size_t src_length, const Charset::Tables& tables); | 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 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_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 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_UTF8(XMLByte* src, size_t src_length); |
| static size_t calc_JSON_escaped_length(XMLByte* src, size_t src_length, const Charset::Tables& tables); | 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 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_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); | 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: | public: |
| /// converts xmlChar* null-terminated string to char* | /// converts xmlChar* null-terminated string to char* |
| String::C transcode_cstr(const xmlChar* s); | String::C transcode_cstr(const xmlChar* s); |
| Line 194 size_t getUTF8CharPos(const XMLByte* src | Line 172 size_t getUTF8CharPos(const XMLByte* src |
| size_t lengthUTF8(const XMLByte* srcBegin, const XMLByte* srcEnd); | size_t lengthUTF8(const XMLByte* srcBegin, const XMLByte* srcEnd); |
| unsigned int lengthUTF8Char(const XMLByte c); | unsigned int lengthUTF8Char(const XMLByte c); |
| const char *fixUTF8(const char *src); | |
| class UTF8_string_iterator { | class UTF8_string_iterator { |
| public: | public: |