Skip to Content »

FlashApe » Newlines in xml

 Newlines in xml

  • July 10th, 2007
  • 11:25 am

I was trying to split a string on a newline character today and having some issues. The string was a text node loaded from an xml file, and i could see that the line breaks were coming in intact. However when i tried to split the string on the “\n” character, it wouldn’t work. Long story short, internally flash represents a newline character as “\r”, so string.split(”\r”) works fine.

2 People had this to say...

Gravatar

That’s certainly one thing that I wish was more consistent across systems. In Javascript, I am pretty sure the line break is \n, not \r. On Windows machines, I think they use \r\n. On *nix machines I think they use just \n. In ColdFusion, GetToken() won’t use both \r and \n as a token delimiter, just one (but I can’t remember which one, I think \n).

Anyhow, it’s frustrating and I wish it was more consistent.

Gravatar
  • Zach
  • October 14th, 2007
  • 10:38 pm

Thanks! You just saved me several minutes of grief…

Want your say?

* Required fields. Your e-mail address will not be published on this site


You can use the following XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>