Re: [xml] New user - UTF-16 issue



On 2 June 2010 16:41,  <Ramsundar_Govindaraj dell com> wrote:
Hi,



ÂI know this issue might have been asked a thousand times over, but ÂI am
not able to resolve the issue. My situation is this.



1.ÂÂÂÂÂÂ I have an xml file called b.xml whose encoding attribute is UTF-16.
(attached along with this email)

2.ÂÂÂÂÂÂ I embed this file as a resource into my visual studio project.

3.ÂÂÂÂÂÂ When the project starts up, I read this file into a variable and
need to pass it to Libxml2 to parse. How do I accomplish it?



The problems:



1.ÂÂÂÂÂÂ I cannot read the file into a char* as this file contains Âwide
characters. So I load them on to a wstring. ÂAfter which I realized ÂLibxml2
constraints of not allowing wchar strings. So I am trying to convert my
wchar* to char* .

2.ÂÂÂÂÂÂ Again I have 2 options here : either bad cast it or use
WidetoMultiByte to convert to char*. I did both of them.



3.ÂÂÂÂÂÂ After this, ÂI called XmlReadMemory API in which I understand I can
specify the encoding. IÂ gave NULL and UTF-16 in 2 separate attempts.



4.ÂÂÂÂÂÂ At the end of it, I cannot correctly parse and I get a NULL
xmlDocPtr. Any ideas on how should I go about solving this?



Thanks,

Ram



_______________________________________________
xml mailing list, project page Âhttp://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml



Does/will/can the endian make a difference?

My editor says the file is UTF-16 LE (Little Endian).

Is having a BOM normal? Does the file need to be BE for VS?







-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling



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