RE: [xml] UTF8Toisolat1() usage

"Markus" == Henke, Markus <Markus_Henke ordat com> writes:

    > Hi Geert, all,
    >> -----Original Message-----
    >> From: Geert Kloosterman [mailto:geertk ai rug nl]
    >> Sent: Monday, June 03, 2002 4:09 PM
    >> To: xml gnome org
    >> Subject: [xml] UTF8Toisolat1() usage
    >> Hi all,
    >> How can I convert the result from xmlNodeListGetString() to
    >> iso-8859-1?  
    >> I think I have to use UTF8Toisolat1(), but it isn't exactly clear to
    >> me how to use the function with respect to memory allocation.  Do I
    >> need to supply a buffer that's large enough myself, or does the
    >> function allocate it for me?
    >> Geert

    > It's been a while that i've looked at the corresponding code,
    > but i'm quite sure that "UTF8Toisolat1()" won't handle the buffer
    > size for you.
    > You can use "xmlCharEncOutFunc()" (get the encoding handler using
    > "xmlGetCharEncodingHandler()") to convert from UTF-8 to ISO-8859-1,
    > it uses xmlBuffer for in/out parameters and handles the buffer size.

Thanks.  So the idiom to convert an UTF8 xmlChar * to an iso-8859-1
char * is:

    - setup an encoding handler with xmlGetCharEncodingHandler()
    - create input and output buffers with xmlBufferCreate()
    - transfer the UTF8 xmlChar * to an xmlBufferPtr with xmlBufferCat()
    - translate to iso-8859-1 using xmlCharEncOutFunc()
    - put the iso-8859-1 results in an xmlChar * using xmlBufferContent()
    (- cast the xmlChar * to char * ????)

    --> for iso-8859-1 output use xmlBufferDump() on the buffer

Am I correct?


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