Click to See Complete Forum and Search --> : UTF - 16 gives error


August 7th, 2000, 10:23 PM
Hi all,

i have a problem with UTF - 8 and UTF 16 encoding formats.

My problem is that
1) if i save the xml- file as unicode with encoding style as UTF-16 my application reports SAXParserException saying 'Document root element is missing"

2) if i save the xml file as a non-unicode format and specify encoding as UTF-16
application reports "Missing byte-order mark"

3) if i save the xml- file as unicode with encoding style as UTF-8 my application reports SAXParserException saying 'Document root element is missing"

Could someone tell me what's happening or how i could solve this

thanks in advance

shreya

charlass
August 10th, 2000, 01:06 AM
If you save it as UTF16, the first byte of your text file should be 0xFFFE.
Also the first line should be:


Your attempts 2) and 3) can't work, they just don't match.

Do you give your parser a URL (so it reads the file itself) or a huge string (with your XML data)?

shreya
August 14th, 2000, 02:03 AM
Hi,

Thanks for the reply. I was able to read the doc properly.

Now i have another question.

How can i retrieve the encoding format from the XML.

Since if i hardcode it to UTF-16, UTF-8 gives an error and vice versa.

thanks

Shreya

JonaChong
June 28th, 2002, 12:21 AM
I am having the same problem.
I managed to save it in Unicode format however IE keeps reports an error "A name was started with an invalid character......"

This is the string I have:

<?xml version="1.0" encoding="UTF-16"?>
<event>
<selections categ="more">
<selection type="Total Cards" sel_id="305655" sel_stat="active" price="5" sel_name="Vålerenga"></selection>
</selections>
</event>

Would appreciate if you could give same hints on how to over come it?