[xml] Using wchar_t string with libxml2.




You'll have to excuse my newness to libxml and unicode in general, but please bare with me. I've read through the http://xmlsoft.org/encoding.html document and some of the unicode intros on www.unicode.org, but I could do with some help actually coding this.

I have an mfc window app that uses wchar_t strings (WCHAR and CStringW too), for holding my data. I'd like to write this data out to an xml file. As I'm building up the xml tree, I get unstuck as all the functions expect an xmlChar* parameters. When I try to cast my wide strings into xmlChar strings, only the first letter is written out. (I just call xmlSaveFile() to write out).

In the past when I've worked with normal char* strings, I just cast (BAD_CAST) them into xmlChar* strings. This seemed to work ok.  

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?

If anyone has any good code examples on building and writing out an xml file from a bunch of wchar strings, that would be really handy. Thanks.

Arthur Yarwood



**********************************************************************
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]