• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic