Encoding problem using SAXBuilder

Hello,

I am getting the next exception only with international characters, in this case m閤ico, the "? is the problem, mexico wouldn磘 be a problem:

2006-09-11 09:29:28,977 INFO [http-8080-Processor18] util.XMLParser (XMLParser.java:102) - 0

strXml: <?xml version="1.0" encoding="UTF-8"?><actions><action name="test" type="request"><parameters><parameter name ="textToSearch">m閤ico</parameter><parameter name ="tabNumber">1</parameter><parameter name ="fromPortal">false</parameter><parameter name ="offset">0</parameter><parameter name ="breadCrumb"></parameter><parameter name ="filter"></parameter><parameter name ="numHits"></parameter><parameter name ="action">searchSite</parameter></parameters></action></actions>

org.jdom.input.JDOMParseException: Error on line 1: Character conversion error:"Malformed UTF-8 char -- is an XML encoding declaration missing?" (line number may be too low).

at org.jdom.input.SAXBuilder.build(SAXBuilder.java:468)

at org.jdom.input.SAXBuilder.build(SAXBuilder.java:770)

at com.ge.search.util.XMLParser.parseXMLRequest(XMLParser.java:104)

when trying to do this:

ByteArrayInputStream bais =new ByteArrayInputStream(strXml

.getBytes());

Document doc = builder.build(bais);//this line throws the exception

This is the first time I am dealing with encoding issues, can you tell me why I am getting this exception? Thanks.

Message was edited by:

gaboZ

[2011 byte] By [gaboZa] at [2007-10-3 4:41:22]
# 1

Probably some bozo has produced a malformed XML file using this process:

1. Create an XML file whose encoding is not UTF-8. Write non-ASCII data into the file using this non-UTF-8 encoding.

2. Have the XML file declare that its encoding is UTF-8.

Send that XML file back to whoever produced it and let them know that it is malformed because it lies about its encoding.

DrClapa at 2007-7-14 22:45:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Thanks DrClap, you gave me the clue to solve the problem
gaboZa at 2007-7-14 22:45:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...