This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Convert special characters to readable ones Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Convert special characters to readable ones" Watch "Convert special characters to readable ones" New topic
Author

Convert special characters to readable ones

Pavan Kashyap
Greenhorn

Joined: Jul 18, 2006
Posts: 8
Hi,
I am getting an error, which says The character '' is an invalid character. Actually i am trying to create an xml from the data that comes from the database. In that data this character is there and it is not accepting this.

The data comes from a different language. I tried using UTF-8 and ISO-8859-1 for the encoding, but didnt get resolved.

I need to convert this character so that xml can handle that.

Please let me know for any solution.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

What is the encoding that the database uses and what is the encoding that the target XML file should use ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Pavan Kashyap
Greenhorn

Joined: Jul 18, 2006
Posts: 8
I am not sure of the encoding on the database side, from the xml side i am currently using "UTF-8" for encoding
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It looks like your character is U+0008, or hex-08 if you like. This character is not permitted in any XML document, so what you have there is not a well-formed XML document. Encoding doesn't have anything to do with it.

You are producing this document from a database? Then you will have to filter out invalid characters before writing the others to the document. And you will need to know which characters are permitted and which ones aren't. The XML Recommendation tells you that; section 2.2 is the part you should particularly read.
 
jQuery in Action, 2nd edition
 
subject: Convert special characters to readable ones
 
Similar Threads
Parsing BLOB datatype
how to append the contents of an ArrayList
Formatting xml using java
Conversion to Packed Data
how to handle xml as strings?