[ExtendScript] Line feed \u000A character assigned to text contents is converted to carriage return
MacOS 13.3.1, Adobe Illustrator 27.4.1
Also reported on Windows same version of Illustrator.
Steps to reproduce.
To see problem, run this script
```
(function () {
var doc = app.documents.add();
var tf1 = doc.textFrames.add();
tf1.position = [100, 100];
tf1.contents = 'Break\u000Ame.';
alert('Linefeed (10)\n charCode = ' + tf1.contents.charCodeAt(5));
var tf2 = doc.textFrames.add();
tf2.position = [200, 100];
tf2.contents = 'Break\u0003me.';
alert('End-of-text (3)\n charCode = ' + tf2.contents.charCodeAt(5));
})();
```
I would expect the text on the left to have a line feed (u+000A) character, but it is converted to a carriage return (u+000D).
The text on the right is a workaround, using an unexpected character (u+0003).
There is a discussion here.
This silent conversion is unexpected, and never wanted by the user (the scripter).
-
Dave Myron commented
It seems that the Extendscript File object write() and writeln() do this as well. It's *very* surprising to silently convert characters.
For example, this explicit use of write converts the newline to a carriage return:
`var f = new File("/tmp/test.log"); f.open("w"); f.write("test\n"); f.close();`Results:
```> hexdump /tmp/test.log
0000000 6574 7473 000d
0000005
```Same results if I replace `write("test\n")` with `writeln("test")`!
Terrible!