toml-lang / toml.io

Source Code for toml.io
https://toml.io
MIT License
42 stars 44 forks source link

Clarification on normalizing newlines in a string literal #76

Closed TonalidadeHidrica closed 1 year ago

TonalidadeHidrica commented 1 year ago

The toml language states:

TOML parsers should feel free to normalize newline to whatever makes sense for their platform.

I am not sure how to interpret "should feel free". Is it obligatory to interpret the newline according to what platform the parser is running on, or is it allowed to be parser-dependent on how to interpret newlines in a stirng literal?

arp242 commented 1 year ago

It's parser-dependent; you can change the newlines from \n\r\n if you think that makes sense, but you don't need to.

(For my parser I just leave them alone, e.g. if you put a \r\n in the file you will always get a \r\n out and if you put a \n in there you always get a \n out; auto-changing newlines always confuses me, but some people seem to like it).

TonalidadeHidrica commented 1 year ago

Thanks for the clarification!