|
|
| version 1.33.2.19.2.12, 2003/03/26 18:52:50 | version 1.33.2.19.2.14, 2003/04/02 10:50:53 |
|---|---|
| Line 504 void Charset::transcodeToCharset( | Line 504 void Charset::transcodeToCharset( |
| } | } |
| #ifdef XML | #ifdef XML |
| static int xml256CharEncodingInputFunc ( | |
| unsigned char *out, | |
| int *outlen, | |
| const unsigned char *in, | |
| int *inlen, | |
| void *info) { | |
| return transcodeToUTF8( | |
| in, *(size_t*)inlen, | |
| out, *(size_t*)outlen, | |
| *(const Charset::Tables *)info); | |
| } | |
| static int xml256CharEncodingOutputFunc ( | |
| unsigned char *out, | |
| int *outlen, | |
| const unsigned char *in, | |
| int *inlen, | |
| void *info) { | |
| return transcodeFromUTF8( | |
| in, *(size_t*)inlen, | |
| out, *(size_t*)outlen, | |
| *(const Charset::Tables *)info); | |
| } | |
| static const Charset::Tables* tables[MAX_CHARSETS]; | |
| #define declareXml256ioFuncs(i) \ | |
| static int xml256CharEncodingInputFunc##i( \ | |
| unsigned char *out, int *outlen, \ | |
| const unsigned char *in, int *inlen,void*) { \ | |
| return transcodeToUTF8( \ | |
| in, *(size_t*)inlen, \ | |
| out, *(size_t*)outlen, \ | |
| *tables[i]); \ | |
| } \ | |
| static int xml256CharEncodingOutputFunc##i( \ | |
| unsigned char *out, int *outlen, \ | |
| const unsigned char *in, int *inlen,void*) { \ | |
| return transcodeFromUTF8( \ | |
| in, *(size_t*)inlen, \ | |
| out, *(size_t*)outlen, \ | |
| *tables[i]); \ | |
| } | |
| declareXml256ioFuncs(0) declareXml256ioFuncs(1) | |
| declareXml256ioFuncs(2) declareXml256ioFuncs(3) | |
| declareXml256ioFuncs(4) declareXml256ioFuncs(5) | |
| declareXml256ioFuncs(6) declareXml256ioFuncs(7) | |
| declareXml256ioFuncs(8) declareXml256ioFuncs(9) | |
| static xmlCharEncodingInputFunc inputFuncs[MAX_CHARSETS]={ | |
| xml256CharEncodingInputFunc0, xml256CharEncodingInputFunc1, | |
| xml256CharEncodingInputFunc2, xml256CharEncodingInputFunc3, | |
| xml256CharEncodingInputFunc4, xml256CharEncodingInputFunc5, | |
| xml256CharEncodingInputFunc6, xml256CharEncodingInputFunc7, | |
| xml256CharEncodingInputFunc8, xml256CharEncodingInputFunc9 | |
| }; | |
| static xmlCharEncodingOutputFunc outputFuncs[MAX_CHARSETS]={ | |
| xml256CharEncodingOutputFunc0, xml256CharEncodingOutputFunc1, | |
| xml256CharEncodingOutputFunc2, xml256CharEncodingOutputFunc3, | |
| xml256CharEncodingOutputFunc4, xml256CharEncodingOutputFunc5, | |
| xml256CharEncodingOutputFunc6, xml256CharEncodingOutputFunc7, | |
| xml256CharEncodingOutputFunc8, xml256CharEncodingOutputFunc9 | |
| }; | |
| static size_t handlers_count=0; | |
| void Charset::addEncoding(char *name_cstr) { | void Charset::addEncoding(char *name_cstr) { |
| if(handlers_count==MAX_CHARSETS) | |
| throw Exception(0, | |
| 0, | |
| "already allocated %d handlers, no space for new encoding '%s'", | |
| MAX_CHARSETS, name_cstr); | |
| xmlCharEncodingHandler* handler=new(PointerFreeGC) xmlCharEncodingHandler; | xmlCharEncodingHandler* handler=new(PointerFreeGC) xmlCharEncodingHandler; |
| handler->name=name_cstr; | { |
| handler->input=xml256CharEncodingInputFunc; handler->inputInfo=&tables; | handler->name=name_cstr; |
| handler->output=xml256CharEncodingOutputFunc; handler->outputInfo=&tables; | handler->input=inputFuncs[handlers_count]; |
| handler->output=outputFuncs[handlers_count]; | |
| ::tables[handlers_count]=&tables; | |
| handlers_count++; | |
| } | |
| xmlRegisterCharEncodingHandler(handler); | xmlRegisterCharEncodingHandler(handler); |
| } | } |
| void Charset::initTranscoder(const String& name, const char* name_cstr) { | void Charset::initTranscoder(const String& name, const char* name_cstr) { |
| Line 563 const char* Charset::transcode_cstr(xmlC | Line 592 const char* Charset::transcode_cstr(xmlC |
| if(xmlCharEncodingOutputFunc output=transcoder(fname).output) { | if(xmlCharEncodingOutputFunc output=transcoder(fname).output) { |
| error=output( | error=output( |
| (unsigned char*)out, &outlen, | (unsigned char*)out, &outlen, |
| (const unsigned char*)s, &inlen, | (const unsigned char*)s, &inlen,0); |
| transcoder(fname).outputInfo); | |
| } else { | } else { |
| memcpy(out, s, outlen=inlen); | memcpy(out, s, outlen=inlen); |
| error=0; | error=0; |
| Line 598 void* Charset::transcode_buf2mchar(trans | Line 626 void* Charset::transcode_buf2mchar(trans |
| out=(unsigned char*)malloc_func(outlen+1); | out=(unsigned char*)malloc_func(outlen+1); |
| error=input( | error=input( |
| out, &outlen, | out, &outlen, |
| (const unsigned char *)buf, (int *)&buf_size, | (const unsigned char *)buf, (int *)&buf_size,0); |
| transcoder(fname).inputInfo); | |
| } else { | } else { |
| outlen=buf_size; | outlen=buf_size; |
| out=(unsigned char*)malloc_func(outlen+1); | out=(unsigned char*)malloc_func(outlen+1); |