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

Having a BOM for UTF-16 for Little Endian is required, it can be
present for Big Endian, an if there is no BoM present Big Endian is
assumed.  That is what The Unicode Consortium has to say about it
anyway. If there is no BOM there are other suggestions made by the xml
spec to determine various encodings indicating UTF-16, UTF-32, and one
or two others when there is no BoM.

In any case, as long as the resource is treated as a binary resource
when storing and retrieving it there should be no issue in VS. if the
XML is compliant because libxml2 takes care all of that transcoding
for you.  If you are asking if the editor handles UTF-16LE, yes it

On Fri, Jun 4, 2010 at 2:14 AM, Richard Quadling <rquadling gmail com> wrote:
On 2 June 2010 16:41,  <Ramsundar_Govindaraj dell com> wrote:

 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?



xml mailing list, project page
xml gnome org

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 :
EE4Free :
Zend Certified Engineer :
xml mailing list, project page
xml gnome org

If there is anything bigger than my ego around, I want it caught and shot now!

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