aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Strange Characters in TextPanes... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Strange Characters in TextPanes..." Watch "Strange Characters in TextPanes..." New topic
Author

Strange Characters in TextPanes...

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
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

Joined: Oct 27, 2005
Posts: 19670
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
Ah Ok, I was thinking I had to escape the number, thanks.

-Tad
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
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

Joined: Nov 16, 2004
Posts: 264
Nm finally found a regex([^\\p{Graph}]) that worked to get rid of it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strange Characters in TextPanes...