File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes identify and replace special character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "identify and replace special character" Watch "identify and replace special character" New topic
Author

identify and replace special character

tormod eriksen
Ranch Hand

Joined: Jan 23, 2002
Posts: 52
I am to replace a specific set of characters in a textfile with another specific set of characters.
I stumble upon two problematic characters.
In my textfile reader they show as a general character (it can't show it), but in HEX mode one is represented by 9D and the ohter by 8F.
When I read in the string in java, and try s = s.replace('\u009D', '<character of choice>'), the character isn't replaced.
When I output the string the 9D and 8F characters show as ? (a question mark)
Any ideas how I can replace these characters would by highly appreciated!
Jon Dornback
Ranch Hand

Joined: Apr 24, 2002
Posts: 137
Originally posted by tormod eriksen:
I am to replace a specific set of characters in a textfile with another specific set of characters.
I stumble upon two problematic characters.
In my textfile reader they show as a general character (it can't show it), but in HEX mode one is represented by 9D and the ohter by 8F.
When I read in the string in java, and try s = s.replace('\u009D', '<character of choice>'), the character isn't replaced.
When I output the string the 9D and 8F characters show as ? (a question mark)
Any ideas how I can replace these characters would by highly appreciated!


java is naturally inclined to use latin iso-1, but it appears you are reading in from a different char set. if you post some more code we can take a look to see if you are reading in the characters correctly. where are you trying to print them, and how? look here for a helpful tutorial by one of the guys on the original oak team:
in depth look at java characters


use the [CODE] tags - it makes it much easier for people to help you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: identify and replace special character