Re: [xml] please, help with xmlFindCharEncodingHandler() or iconv?

Hi Vladimir,

How can I convert character strings inside my program from utf-8 to
windows-1251 (russian symbols)?
I can read from and write to the xml-file in windows-1251, but I can
not convert utf-8 to windows-1251 INSIDE the program.

Your first possibility would be to use iconv directly, see the iconv
documention for this.

I used function
handler = xmlFindCharEncodingHandler( "windows-1251" );

and handler returned !=0, but handler->output == handler->input==0.
So, I can not use the libxml-document's example.
By the way, I saw there is handler->iconv_in!=0 and handler->iconv_out!=0.
Should I use them? But how? 

You can use such handlers with the functions (from encoding.c):

int xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
                 xmlBufferPtr in);
int xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
                 xmlBufferPtr in);
int xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
                  xmlBufferPtr in);
int xmlCharEncCloseFunc(xmlCharEncodingHandler *handler);

Peter Jacobi

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]