• 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
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

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
 
Sheriff
Posts: 22813
132
Eclipse IDE Spring 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.
 
What a show! What atmosphere! What fun! What a tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic