|
|
| version 1.38.2.1, 2003/11/05 13:53:30 | version 1.45, 2003/12/19 10:39:05 |
|---|---|
| Line 5 | Line 5 |
| Author: Alexander Petrosyan<paf@design.ru>(http://paf.design.ru) | Author: Alexander Petrosyan<paf@design.ru>(http://paf.design.ru) |
| */ | */ |
| static const char* IDENT_CHARSET_C="$Date$"; | static const char * const IDENT_CHARSET_C="$Date$"; |
| #include "pa_charset.h" | #include "pa_charset.h" |
| #include "pa_charsets.h" | #include "pa_charsets.h" |
| Line 126 void Charset::load_definition(Request_ch | Line 126 void Charset::load_definition(Request_ch |
| // parse cells | // parse cells |
| char *row; | char *row; |
| while(row=getrow(&data)) { | while((row=getrow(&data))) { |
| // remove empty&comment lines | // remove empty&comment lines |
| if(!*row || *row=='#') | if(!*row || *row=='#') |
| continue; | continue; |
| Line 134 void Charset::load_definition(Request_ch | Line 134 void Charset::load_definition(Request_ch |
| // char white-space digit hex-digit letter word lowercase unicode1 unicode2 | // char white-space digit hex-digit letter word lowercase unicode1 unicode2 |
| unsigned int c=0; | unsigned int c=0; |
| char *cell; | char *cell; |
| for(int column=0; cell=lsplit(&row, '\t'); column++) { | for(int column=0; (cell=lsplit(&row, '\t')); column++) { |
| switch(column) { | switch(column) { |
| case 0: c=to_wchar_code(cell); break; | case 0: c=to_wchar_code(cell); break; |
| // pcre_tables | // pcre_tables |
| Line 439 const String::C Charset::transcodeToUTF8 | Line 439 const String::C Charset::transcodeToUTF8 |
| (XMLByte *)src.str, src_length, | (XMLByte *)src.str, src_length, |
| dest_body, dest_length, | dest_body, dest_length, |
| tables)<0) | tables)<0) |
| throw(0, 0, | throw Exception(0, |
| 0, | 0, |
| "Charset::transcodeToUTF8 buffer overflow"); | "Charset::transcodeToUTF8 buffer overflow"); |
| Line 519 static void change_case_UTF8(XMLCh src, | Line 519 static void change_case_UTF8(XMLCh src, |
| const Charset::UTF8CaseTable& table) { | const Charset::UTF8CaseTable& table) { |
| store_UTF8(change_case_UTF8(src, table), outPtr); | store_UTF8(change_case_UTF8(src, table), outPtr); |
| }; | }; |
| void change_case_UTF8(const XMLByte* srcData, XMLByte* toFill, | void change_case_UTF8(const XMLByte* srcData, size_t srcLen, |
| const Charset::UTF8CaseTable& table) { | XMLByte* toFill, size_t toFillLen, |
| const Charset::UTF8CaseTable& table) { | |
| const XMLByte* srcPtr=srcData; | const XMLByte* srcPtr=srcData; |
| const XMLByte* srcEnd=srcData+srcLen; | |
| XMLByte* outPtr=toFill; | XMLByte* outPtr=toFill; |
| XMLByte* outEnd=toFill+toFillLen; | |
| // We now loop until we either run out of input data, or room to store | |
| while ((srcPtr < srcEnd) && (outPtr < outEnd)) { | |
| // Get the next leading byte out | |
| const XMLByte firstByte =* srcPtr; | |
| // Get the next leading byte out | |
| while (const XMLByte firstByte = *srcPtr) { | |
| if(firstByte<= 127) { | if(firstByte<= 127) { |
| change_case_UTF8(firstByte, outPtr, table); | change_case_UTF8(firstByte, outPtr, table); |
| srcPtr++; | srcPtr++; |
| Line 583 const String::C Charset::transcodeFromUT | Line 589 const String::C Charset::transcodeFromUT |
| (XMLByte *)src.str, src_length, | (XMLByte *)src.str, src_length, |
| dest_body, dest_length, | dest_body, dest_length, |
| tables)<0) | tables)<0) |
| throw(0, 0, | throw Exception(0, |
| 0, | 0, |
| "Charset::transcodeFromUTF8 buffer overflow"); | "Charset::transcodeFromUTF8 buffer overflow"); |
| Line 665 void Charset::addEncoding(char *name_cst | Line 671 void Charset::addEncoding(char *name_cst |
| "already allocated %d handlers, no space for new encoding '%s'", | "already allocated %d handlers, no space for new encoding '%s'", |
| MAX_CHARSETS, name_cstr); | MAX_CHARSETS, name_cstr); |
| xmlCharEncodingHandler* handler=new(PointerFreeGC) xmlCharEncodingHandler; | xmlCharEncodingHandler* handler=new(UseGC) xmlCharEncodingHandler; |
| { | { |
| handler->name=name_cstr; | handler->name=name_cstr; |
| handler->input=inputFuncs[handlers_count]; | handler->input=inputFuncs[handlers_count]; |
| Line 818 struct Transcode_pair_info { | Line 824 struct Transcode_pair_info { |
| const Charset* dest_transcoder; | const Charset* dest_transcoder; |
| }; | }; |
| #endif | #endif |
| static void transcode_pair(const String::Body akey, | static void transcode_pair(const String::Body /*akey*/, |
| String::Body& avalue, | String::Body& avalue, |
| Transcode_pair_info* info) { | Transcode_pair_info* info) { |
| avalue=Charset::transcode(avalue, | avalue=Charset::transcode(avalue, |