Re: [xml] UTF8Toisolat1() usage
- From: Daniel Veillard <veillard redhat com>
- To: Geert Kloosterman <geertk ai rug nl>
- Cc: "'xml gnome org'" <xml gnome org>
- Subject: Re: [xml] UTF8Toisolat1() usage
- Date: Wed, 5 Jun 2002 02:48:36 -0400
On Tue, Jun 04, 2002 at 07:44:16PM +0200, Geert Kloosterman wrote:
"Markus" == Henke, Markus <Markus_Henke ordat com> writes:
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?
That's the most complicated way to do it I would think of, but yes this
should work.
But I lack to see the fundamental complexity that seems to prevent
you from directly using UTF8Toisolat1
/**
* UTF8Toisolat1:
* @out: a pointer to an array of bytes to store the result
* @outlen: the length of @out
* @in: a pointer to an array of UTF-8 chars
* @inlen: the length of @in
*
* Take a block of UTF-8 chars in and try to convert it to an ISO Latin 1
* block of chars out.
*
* Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
* The value of @inlen after return is the number of octets consumed
* as the return value is positive, else unpredictable.
* The value of @outlen after return is the number of ocetes consumed.
*/
int
UTF8Toisolat1(unsigned char* out, int *outlen,
const unsigned char* in, int *inlen);
Which translated to english means:
"here are my input, here is the output memory area, their size, please
convert and return back the size of the data consumed and produced."
But heck you can certainly use something more complex if you want to !
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]