Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • 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
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

line feed

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting a String from a TextArea. Ascii 10 and 9 convert to blocks
[]. I want to convert these blocks to the unicode linefeed and tab, put cannot. How would I replace these blocks with the proper unicode characters. I am using 1.3, and cannot change. Thanks
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In 1.3 you don't get String.replace() but you can write your own using indexOf() and substring() to find the delimiters and break up the bits. Here's part of one I did in my first J++ project:

Ouch, this is pretty bad! See if you can make it a lot better by keeping the output separate from the input. This also loops until the heap explodes if "new" contains "old", eg replace "BERT" by "ROBERT".
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


the above snippet replaces the '[' character. you can customise it accordingly to replace whichever character you want.
 
Jim Frank
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I can replace the block, but the Unicode character comes out as a block too. I converted to a byte array and the value is 10, but it still comes out as a block in the String. Is this a problem with 1.2, 1.3?
I use \n and other unicode values to replace what is in there.
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic