[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Reply Bookmark it! Watch this topic JavaRanch » Forums » Engineering » XML and Related Technologies
 
RSS feed
 
New topic
Author

Invalid byte 1 of 1-byte UTF-8 sequence

Santiago Rodriguez
Greenhorn

Joined: Aug 16, 2006
Messages: 10

Hi
I have the next error when I try to transform a xml and xls in pdf (FOP)
javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Invalid byte 1 of 1-byte UTF-8 sequence.|#]

Please help me...
Thanks
Santiago
Paul Clapham
Bartender

Joined: Oct 14, 2005
Messages: 7193

That means your document isn't actually encoded in UTF-8, but you are reading it as though it were. This is often because whoever created the document failed to specify its encoding in the prolog.

So send it back to whoever created it and ask them to fix it up. If you don't feel you have the technical background to back up that claim yourself (and you probably shouldn't) then read this tutorial first:

http://skew.org/xml/tutorial/
Ramamoorthy Govindaraj
Greenhorn

Joined: Dec 31, 2009
Messages: 1

I got the same exception. Fortunately, I resolved in the following ways, this code will help for others.

String output = "some contents...go here."; //or input from other
String s = new String(output.getBytes(),"UTF-8");//force to convert UTF-8 standard will address this issue Invalid byte 1 of 1-byte UTF-8 sequence
Writer writer = new BufferedWriter(new FileWriter("c:/temp/Jasper/invoice.html"));
try{
writer.write(s);
}finally{
writer.close();
}
Paul Clapham
Bartender

Joined: Oct 14, 2005
Messages: 7193

That may work in the sense that it won't throw the exception any more. It may not prevent damage to the data caused by failing to read the document using UTF-8 in the first place.

You may well have seen pages on the web with things like Euro signs and A-with-a-hat characters where there should have been quotes or dashes. This is the sort of thing that happens if you don't use the right encodings.
 
jQuery in Action
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Engineering » XML and Related Technologies
 
RSS feed
 
New topic
IntelliJ open source

.