Re: [xml] Using wchar_t string with libxml2.



Daniel Veillard wrote:
On Wed, Jan 26, 2005 at 02:05:31PM +0000, Arthur Yarwood wrote:
  
xml-bounces gnome org wrote on 26/01/2005 12:48:07:
    
I'm guessing I've got the wrong code for 
the input. Any ideas?
    

  http://www.opengroup.org/onlinepubs/007908799/xsh/stddef.h.html
  the definition of wchar_t doesn't define an encoding. Seems to be
a sequence of code point. Doesn't even define the *size* of the C objects,
maybe your encoding is UCS4 but you really ought to know better what
you are using. It's likely to even be system dependant ! Anyway if you
use embedded systems that sounds a sure way to waste globs of memory,
I would not do that...
  UTF-8 representation is defined in rfc2044 . 
  libxml2 has a function to take an Unicode code point and write it
in an xmlChar buffer:
  http://xmlsoft.org/html/libxml-parserInternals.html#xmlCopyCharMultiByte

  
Found a windows function called WideCharToMultiByte() that seems to do the job. It can convert to a UTF-8 multibyte string stored in char's. Seems to work ok.
Think the problem I had with iconv, is that it can accept wchar_t as an encoding type, but I don't think it was compiled in the version I was using. :(

According to MSDN, the wchar_t is an unsigned short (16bits). I think the encoding is system dependant. The above function apparently sort it out.

No, I'm not working on embedded stuff. Just some MFC apps, where all the control etc use wchar_t's to handle unicode.

Thanks for you help.

Arthur.





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