I can't find anything like this in stdlib.

Maybe you're remembering something like `ospaths.DirSep` or Python's 
[os.linesep](https://docs.python.org/3/library/os.html#os.linesep)?

System 
[readline](https://github.com/nim-lang/Nim/blob/master/lib/system.nim#L3135) 
works with either line ending. 
[strutils.NewLines](https://github.com/nim-lang/Nim/blob/master/lib/pure/strutils.nim#L58)
 is not OS dependent.

Looking at [Wikipedia Newline article's Representation 
table](https://en.wikipedia.org/wiki/Newline#Representation) and the 
[platforms](https://github.com/nim-lang/Nim/blob/devel/lib/system/platforms.nim)
 explicitly supported by Nim, the code would be something like:
    
    
    const lineSep: set[char] =
      when defined(macos):
        {'\r'}
      elif defined(netware):
        {'\n', '\r'}
      elif defined(windows) or defined(dos) or defined(os2) or
            defined(atari) or defined(palm):
        {'\r', '\n'}
      else:
        {'\n'}
    
    
    Run

I personally prefer creating files with [POSIX 
standard](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206)
 line endings (just '\n') even on Windows - all major modern apps [(now even 
notepad)](https://blogs.msdn.microsoft.com/commandline/2018/05/08/extended-eol-in-notepad/)
 can handle them just fine. 

Reply via email to