• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange Characters in TextPanes...

 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm importing text documents into a java app and getting some different characters coming into a TextPane. When I open the files in wordpad/notepad they look like blank spaces, when I look at them at a dos prompt using the more function they look like the ascii symbol(225). In the text pane they end up looking like ascii symbol(127) -a box. At some point in time they "auto-magically" become question marks. I'd like to find a way to just strip them out when I load the file. I tried someString.replace('\127', '\0') that didn't work (I'm not sure thats the right way to reference an ascii char by its number.

Any one have any suggestions?

-Tad
 
Rob Spoor
Sheriff
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 127 symbol is often used for any character that cannot be displayed in the current character set - you don't want to know how many I see when visiting Japanese sites

But to answer your question about replacing: ASCII character 127 can be found / replaced by passing the integer 127. Characters are in fact 2 byte unsigned integer numbers, with the integer value matching the ASCII code for ASCII characters.
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah Ok, I was thinking I had to escape the number, thanks.

-Tad
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to figure out how to filter these characters out of my strings and am not having any luck. I've tried the replace/replace all. I've tried writing the document out using different character encodings and am not having any luck. Anyone have any suggestions?


-Tad
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nm finally found a regex([^\\p{Graph}]) that worked to get rid of it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic