• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Strange Characters in TextPanes...

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 22457
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nm finally found a regex([^\\p{Graph}]) that worked to get rid of it.
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic