0

I am using WebStorm on Windows and I have simple command-line dart app:

import 'dart:io';

main(List<String> arguments) {
  File testFile = new File("test.txt");
  testFile.writeAsStringSync("AAA\nBBBBB\rCCCCC");
}

Program executes successfully, however the .txt file opened via Notepad appears to contain

AAABBBBBCCCCC

however if I try to past the content to other environments (WebStorm, StackOverflow question textarea), the text appears as

AAA
BBBBB
CCCCC

I feel like I am missing something basic ... any idea?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Lubomír Grund
  • 145
  • 1
  • 13
  • 1
    As Günter Zöchbauer have said: Windows Notepad recognizes default `CRLF` line endings only while browser/WebStorm will use any of the known ones. AFAIK in latest Windows 10 version (Spring Creators Update or whatever the name is) Notepad finally got learned about other line endings. Try Notepad++ meantime... – LazyOne Jul 02 '18 at 08:03

1 Answers1

2

Windows uses \r\n by default for line endings.

Not all applications treat \r or \n as line ending on windows.
This behavior is not related to Dart in any way, that's just how some applications interpret these codes.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567