|
|
| version 1.33.2.19.2.9, 2003/03/25 10:25:25 | version 1.33.2.19.2.12, 2003/03/26 18:52:50 |
|---|---|
| Line 92 Charset::Charset(const String& aname, co | Line 92 Charset::Charset(const String& aname, co |
| #endif | #endif |
| } | } |
| Charset::~Charset() { | |
| // @todonow unregister encodings | |
| #ifdef XML | |
| // not deleting transcoder, that's not our business | |
| #endif | |
| } | |
| void Charset::load_definition(const String& afile_spec) { | void Charset::load_definition(const String& afile_spec) { |
| // pcre_tables | // pcre_tables |
| // lowcase, flipcase, bits digit+word+whitespace, masks | // lowcase, flipcase, bits digit+word+whitespace, masks |
| Line 449 void Charset::transcodeToUTF8( | Line 442 void Charset::transcodeToUTF8( |
| const void* source_body, size_t source_content_length, | const void* source_body, size_t source_content_length, |
| const void *& adest_body, size_t& dest_content_length) const { | const void *& adest_body, size_t& dest_content_length) const { |
| dest_content_length=source_content_length*6/*so that surly enough, max utf8 seq len=6*/; | dest_content_length=source_content_length*6/*so that surly enough, max utf8 seq len=6*/; |
| XMLByte *dest_body=new XMLByte[dest_content_length]; | XMLByte *dest_body=new(PointerFreeGC) XMLByte[dest_content_length]; |
| if(::transcodeToUTF8( | if(::transcodeToUTF8( |
| (XMLByte *)source_body, source_content_length, | (XMLByte *)source_body, source_content_length, |
| Line 466 void Charset::transcodeFromUTF8( | Line 459 void Charset::transcodeFromUTF8( |
| const void* source_body, size_t source_content_length, | const void* source_body, size_t source_content_length, |
| const void *& adest_body, size_t& dest_content_length) const { | const void *& adest_body, size_t& dest_content_length) const { |
| dest_content_length=source_content_length*6/*so that surly enough, "ÿ" has max ratio */; | dest_content_length=source_content_length*6/*so that surly enough, "ÿ" has max ratio */; |
| XMLByte *dest_body=new XMLByte[dest_content_length]; | XMLByte *dest_body=new(PointerFreeGC) XMLByte[dest_content_length]; |
| if(::transcodeFromUTF8( | if(::transcodeFromUTF8( |
| (XMLByte *)source_body, source_content_length, | (XMLByte *)source_body, source_content_length, |
| Line 482 void Charset::transcodeFromUTF8( | Line 475 void Charset::transcodeFromUTF8( |
| /// transcode using both charsets | /// transcode using both charsets |
| void Charset::transcodeToCharset( | void Charset::transcodeToCharset( |
| const Charset& dest_charset, | const Charset& dest_charset, |
| const void* source_body, size_t source_content_length, | const void* source_body, size_t source_content_length, |
| const void *& adest_body, size_t& adest_content_length) const { | const void *& adest_body, size_t& adest_content_length) const { |
| if(&dest_charset==this) { | if(&dest_charset==this) { |
| adest_body=source_body; | adest_body=source_body; |
| adest_content_length=source_content_length; | adest_content_length=source_content_length; |
| } else { | } else { |
| size_t dest_content_length=source_content_length; | size_t dest_content_length=source_content_length; |
| unsigned char *dest_body=new unsigned char[dest_content_length]; | unsigned char *dest_body=new(PointerFreeGC) unsigned char[dest_content_length]; |
| const XMLByte* srcPtr=(XMLByte *)source_body; | const XMLByte* srcPtr=(XMLByte *)source_body; |
| const XMLByte* srcEnd=(XMLByte *)source_body+source_content_length; | const XMLByte* srcEnd=(XMLByte *)source_body+source_content_length; |
| Line 585 const char* Charset::transcode_cstr(xmlC | Line 578 const char* Charset::transcode_cstr(xmlC |
| return out; | return out; |
| } | } |
| const String& Charset::transcode(xmlChar* s) { | const String& Charset::transcode(xmlChar* s) { |
| return *new String(transcode_cstr(s), 0/*auto-size*/, String::L_CLEAN); | return *new String(transcode_cstr(s), 0/*auto-size*/, true); |
| } | } |
| const char* Charset::transcode_cstr(GdomeDOMString* s) { | const char* Charset::transcode_cstr(GdomeDOMString* s) { |
| return s?transcode_cstr(BAD_CAST s->str):""; | return s?transcode_cstr(BAD_CAST s->str):""; |
| } | } |
| const String& Charset::transcode(GdomeDOMString* s) { | const String& Charset::transcode(GdomeDOMString* s) { |
| return *new String(transcode_cstr(s), 0/*auto-size*/, String::L_CLEAN); | return *new String(transcode_cstr(s), 0/*auto-size*/, true); |
| } | } |
| /// @test less memory using -maybe- xmlParserInputBufferCreateMem | /// @test less memory using -maybe- xmlParserInputBufferCreateMem |