Re: [xml-dev] Unicode problems with XML and HTML files

Petr Kuzel <[email protected]> Fri, 27 Dec 2002 23:45:23 +0100
Newsgroups gmane.comp.java.netbeans.modules.xml.devel
Organization CollabNet Hosting
Message-ID <[email protected]>
Adrian Herscu wrote:

>>>1) Saving XML documents:
>>>Why XML documents encoded as UTF-8 are saved as ANSI encoded?
>> 
>> 
>> They should not be. Can you reproduce it? What about characters
>> that do not have proper representation in ASCII? What about
>> other encodings? What's your JDK? .....
>>  
> 1) Reproduction steps:
> a. Create a XML file;
> b. Set UTF-8 encoding using the customizer;
> c. Save it;
> d. Open it using Windows/Notepad;
> e. File/Save as...  - the encoding will show ANSI (not UTF-8);

It's obvious notepad do not support XML standard so it
must guess.

> f. Change to UTF-8 and save;
> g. Check XML (using the IDE) - you'll get an error:
> "Document root element is missing. [1] "
> that's because the file is read as ASCII encoded, while it is UTF-8
> encoded - so it appears that it contains a few illegal characters at the
> begining (those signal for UTF encoding).

I remember there is a JDK bug. JDK fails on UTF-8 encoded streams
begining with the optional UTF-8 marker character. The marker
character should be filtered out by Reader but it is not. It
confuses the parser. I should work on JDK 1.3 AFAIK.

> 2) I didn't use any characters above the 127 code - all plain English!
> 3) I did try UTF-16 with XML files and it apparently works (it saves as
> little-endian - may be that's because I'm running on Windows?)
> 4) JDK: Java Hotspot Client 1.4.0-b92

If you think that XML module should workaround it then please
fill a bug against it. It's not easy as workaround should be a part
of third party parser - Xerces 2.0.1. (You can try to upgrade it.)

  Thank you
  Cc.