Copy link to clipboard
Copied
Hi,
I'm working on an app that user will be able to change lyrics in input text fields. I have loaded txt file for example like this:
"
|Light|ly |row,| |light|ly |row,|
|O'er |the |glas|sy |waves |we |go!|
|Smooth|ly |glide,| |smooth|ly |glide,|
|On |the |si|lent |tide.|||
"
I let people change lyrics and save it to new txt file. Pipes divides syllables. After user text customization I would like to have text in the same format as original and it's working fine. The thing is I don't know how to deal with line breaks and enter in strings. Output txt file (sent to php sript to write to file) is something like this:
"
|Light|ly |row,| |light|ly |row,||O'er |the |glas|sy |waves |we |go!||Smooth|ly |glide,| |smooth|ly |glide,||On |the |si|lent |tide.|||
"
In output txt file I loose all line break data. But If I copy that txt content to doc file, all line break formating data will be there.
I have tried to loop through output string chars and I found that charcodes 10, and 13 are in place, but not displayed in txt file.
At this stage I would like to replace linebreaks with custom # mark for example. I have tried this:
var charcode:uint = 10;
var char = String.fromCharCode(charcode);
var newString = _newLyrics.replace(char, '#');
But it replaced only first char in string.
How could I use regexp with charcodes ?
How is that char 10, and 13 are displayed in trace statements and actually are in the string but not formatted corectlly in txt file?
Any ideas?
1 Correct answer
a line break is \n and a carriage return is \r. (and, if you need a tab, \t).
Copy link to clipboard
Copied
a line break is \n and a carriage return is \r. (and, if you need a tab, \t).

