Re: [xml] Using wchar_t string with libxml2.




xml-bounces gnome org wrote on 26/01/2005 10:18:34:

> On Wed, Jan 26, 2005 at 10:05:10AM +0000, Arthur_Yarwood scee net wrote:
> > How should I be passing my wide strings into these functions? I could just
> > convert them to char strings, but I could loose data. Are the any other
> > issues I should be concerned about to ensure my xml is valid? e.g.  what
> > encoding standard should I use? UTF-16?
>
>   You must convert your wide strings into UTF-8 strings before passing them
> to the libxml2 API. I think
>     http://xmlsoft.org/encoding.html#internal
> is clear about that. If not I take patches to make this clearer.
>


Ok, does that mean there could possibly be a loss of data, for characters that need two bytes? Or have I got the wrong end of the stick when it comes to storing Unicode strings?

I've just tried using 'wcstombs()' to convert my wide string to a multi-byte string, which I can then BAD_CAST to xmlChar. Is this the correct way of doing this? I just tried passing a random arabic string through wcstombs() and it fails, because it cannot a wide character.

I also tried using iconv (although I wasn't sure what my input code should be utf-16?), this also failed, giving me EILSEQ, again a character it cannot convert.

How should I convert my random arabic string to utf-8? Is it possible?

Thanks,

Arthur.


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
postmaster scee net

This footnote also confirms that this email message has been checked
for all known viruses.

**********************************************************************
Sony Computer Entertainment Europe


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