• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

line feed

 
Jim Frank
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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".
 
Niki Nono
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic