Is \n
the universal newline character sequence in Javascript for all platforms? If not, how do I determine the character for the current environment?
I'm not asking about the HTML newline element (<BR/>
). I'm asking about the newline character sequence used within JavaScript strings.
A note - when using ExtendScript JavaScript (the Adobe Scripting language used in applications like Photoshop CS3+), the character to use is "\r". "\n" will be interpreted as a font character, and many fonts will thus have a block character instead.
For example (to select a layer named 'Note' and add line feeds after all periods):
You can use `` quotes (wich are below Esc button) with ES6. So you can write something like this:
In the response to Nilay above (I cannot comment, not enough reputation):
Tab is a single character, so if you try just %09 it should be fine. An example to see the individual character codes:
The
\n
is just fine for all cases I've encountered. I you are working with web, use\n
and don't worry about it (unless you have had any newline-related issues).