|
|
| version 1.106, 2017/02/07 22:00:41 | version 1.115, 2024/12/11 21:57:35 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: Charset connection implementation. | Parser: Charset connection implementation. |
| Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexander Petrosyan<paf@design.ru>(http://paf.design.ru) | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| #include "pa_charset.h" | #include "pa_charset.h" |
| Line 14 | Line 14 |
| volatile const char * IDENT_PA_CHARSET_C="$Id$" IDENT_PA_CHARSET_H; | volatile const char * IDENT_PA_CHARSET_C="$Id$" IDENT_PA_CHARSET_H; |
| #ifdef XML | #ifdef XML |
| #include "libxml/xmlmemory.h" | |
| #include "libxml/encoding.h" | #include "libxml/encoding.h" |
| #endif | #endif |
| Line 173 void Charset::load_definition(Request_ch | Line 174 void Charset::load_definition(Request_ch |
| case 8: | case 8: |
| // charset | // charset |
| if(tables.toTableSize>MAX_CHARSET_UNI_CODES) | if(tables.toTableSize>MAX_CHARSET_UNI_CODES) |
| throw Exception(PARSER_RUNTIME, &afile_spec, "charset must contain not more then %d unicode values", MAX_CHARSET_UNI_CODES); | throw Exception(PARSER_RUNTIME, &afile_spec, "charset must contain not more than %d unicode values", MAX_CHARSET_UNI_CODES); |
| XMLCh unicode=(XMLCh)to_wchar_code(cell); | XMLCh unicode=(XMLCh)to_wchar_code(cell); |
| if(!unicode && column==7/*unicode1 column*/) | if(!unicode && column==7/*unicode1 column*/) |
| Line 992 void Charset::store_Char(XMLByte*& outPt | Line 993 void Charset::store_Char(XMLByte*& outPt |
| #ifdef XML | #ifdef XML |
| static const Charset::Tables* tables[MAX_CHARSETS]; | static const Charset::Tables* tables[MAX_CHARSETS]; |
| static xmlCharEncodingHandler xml_encoding_handlers[MAX_CHARSETS]; | |
| #ifdef PA_PATCHED_LIBXML_BACKWARD | #ifdef PA_PATCHED_LIBXML_BACKWARD |
| Line 1062 void Charset::addEncoding(char *name_cst | Line 1064 void Charset::addEncoding(char *name_cst |
| if(handlers_count==MAX_CHARSETS) | if(handlers_count==MAX_CHARSETS) |
| throw Exception(0, 0, "already allocated %d handlers, no space for new encoding '%s'", MAX_CHARSETS, name_cstr); | throw Exception(0, 0, "already allocated %d handlers, no space for new encoding '%s'", MAX_CHARSETS, name_cstr); |
| xmlCharEncodingHandler* handler=new xmlCharEncodingHandler; | xmlCharEncodingHandler* handler=&xml_encoding_handlers[handlers_count]; |
| { | { |
| handler->name=name_cstr; | handler->name=name_cstr; |
| handler->input=inputFuncs[handlers_count]; | handler->input=inputFuncs[handlers_count]; |
| Line 1218 size_t getUTF8CharPos(const XMLByte* src | Line 1220 size_t getUTF8CharPos(const XMLByte* src |
| } | } |
| // scan till end but position in bytes still too low | // scan till end but position in bytes still too low |
| throw Exception(0, 0, "Error convertion byte pos to char pos"); | throw Exception(0, 0, "Error conversion byte pos to char pos"); |
| } | } |
| size_t lengthUTF8(const XMLByte* srcBegin, const XMLByte* srcEnd){ | size_t lengthUTF8(const XMLByte* srcBegin, const XMLByte* srcEnd){ |
| Line 1246 const char *fixUTF8(const char *src){ | Line 1248 const char *fixUTF8(const char *src){ |
| do { | do { |
| if(error_offset){ | if(error_offset){ |
| strncpy(dst, src, error_offset); | memcpy(dst, src, error_offset); |
| dst+=error_offset; | dst+=error_offset; |
| src+=error_offset; | src+=error_offset; |