I am generating a file for the user to download, and I want to insert the correct newline character(s) for their platform (\n
, \r
, or \r\n
).
I am aware of the following solutions, but none solve my problem exactly:
- Querying
navigator.platform
ornavigator.appVersion
. These properties are deprecated, so I would prefer not to rely on them. - There are specific approaches for Firefox and NodeJS. These do not apply, as I'm creating a website, and I would prefer if it worked on all browsers.
- There are ways to find the browser's newline characters, but I'm interested in the user's platform. (These are different: Firefox always uses
\n
, regardless of the OS.)