Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

identify and replace special character

 
tormod eriksen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic