File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes encoding doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "encoding doubt" Watch "encoding doubt" New topic
Author

encoding doubt

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Hi,

I have an XML file which contains registered symbol (R and a circle around it).

I am aware that this symbol is in UTF-8 encoding and not in ISO-8859-1.

But when I use ISO-8859-1 encoding scheme for my XML file, browser displays this file properly. But when I use UTF-8, it says:


The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

An invalid character was found in text content. Error processing resource 'file:///


Why so?

Thanks.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

Well, first of all you can put any character into an XML document regardless of the encoding it uses, because you can always use character entities like "&#xxxx;". And well-written XML software will automatically output characters in that way if the target encoding doesn't support them.

The answer to you main question, I think, is that the prolog of the XML document should declare the encoding actually used to write the document. Declaring <?xml encoding="UTF-8"?> is going to cause problems if you don't actually use UTF-8 to write the document.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: encoding doubt