aspose 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
Similar Threads
changing $ to a different character in javascript variable
How can we validate strings for meeting 8-bit US ASCII requirement ?
Problem using the URL button to mark text as a URL
Missing constructor that accepts a String in class Character
textarea