Re: [xml] Target string size after transcoding



On Wed, Sep 23, 2009 at 08:12:13AM -0700, mini thomas wrote:
 
APIs like MultiByteToWideChar has an option to give the number of bytes required by the output string after 
the input is transcoded. 
 
I am using xmlGetCharEncodingHandler and related functions
Is there any way to get the size of output string. ?

  an encoding handler routine does for input or output as a signature:

/**
 * xmlCharEncodingInputFunc:
 * @out:  a pointer to an array of bytes to store the UTF-8 result
 * @outlen:  the length of @out
 * @in:  a pointer to an array of chars in the original encoding
 * @inlen:  the length of @in
 *
 * Take a block of chars in the original encoding and try to convert
 * it to an UTF-8 block of chars out.
 *
 * Returns the number of bytes written, -1 if lack of space, or -2
 *     if the transcoding failed.
 * The value of @inlen after return is the number of octets consumed
 *     if the return value is positive, else unpredictiable.
 * The value of @outlen after return is the number of octets consumed.
 */
typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,
                                         const unsigned char *in, int *inlen);

it certainly returned the number of bytes in the output, outlen and
inlen are also output parameter in addition to the returned value.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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