Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid UTF 8 encoding error. 1

Status
Not open for further replies.

gullyman

Programmer
Mar 7, 2008
1
US
Hello all!
First Let me say that my knowledge of XML is not extensive.
But I know the basic idea.
My problem is this:
I have a Java program that acts as an e mail client and when
I download messages I create an XML file which stores data such as the Subject the FROM and the file which is created from the content.(text, html, jpg etcetera.)
When I want to display the message I parse the xml and display
the data.
This works fine unless the Subject contains a character such as an "e" with an acute accent or umlaut.Then the parser crashes and my data is lost.I get an Invalid UTF 8 encoding error.
My XML has something like this:
Code:
<?xml version= '1.0'?>
<!DOCTYPE VIEWS [
<!ELEMENT VIEWS (VIEW)*>
<!ELEMENT VIEW ( NAME, ITEM, TYPE, TARGET, APP)>
<!ELEMENT NAME (#PCDATA)>
<!ELEMENT ITEM (#PCDATA)>
<!ELEMENT TYPE (#PCDATA)>
<!ELEMENT TARGET (#PCDATA)>
<!ELEMENT APP (#PCDATA)>
]>
<VIEWS>

<VIEW>
<NAME>Incoming View</NAME>
<ITEM>FROM_customerserviceonline@pgecomMessage_Sent_Jan_26_2008_94620_PM_Part_1</ITEM>
<TYPE>EmailSUBJECT_PGE_You_Have_a_New_Energy_Statement</TYPE>
<TARGET>C:/ProDev/ProDev/in/FROM_customerserviceonline@pgecomMessage_Sent_Jan_26_2008_94620_PM_Part_1.html</TARGET>
<APP>ShowMessage</APP>
</VIEW>

</VIEWS>
Can someone point me in the right direction with this?
Any help would be appreciated.
-gullyman
 
Encoding issue traces back to the origin where the document (file/stream) is being prepared. If the encoding is omitted in the prolog, utf-8 is the default. Usually in the windows platform, accute or umlaut more often than not got encoded in iso-8859-1. I am not saying it is experimental science, but to start with try put that encoding into the xml prolog to see what happens.
[tt] <?xml version= '1.0' encoding='iso-8859-1' ?>[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top