I want to programmatically generate tsv files with multi-line cells that stay preserved when opened in Numbers app.
What newline character to use to enable multi-line cells?
CSV is kind of standardized with RFC 4180. For multi-line fields the rules are
If this doesn't work with Numbers, you can also create a Numbers file, add some multi-line fields, export the file as CSV/TSV and verify the encoding/quoting used with TextEdit afterwards.
From the comment of @user3439894:
When Numbers exports to CSV it uses CR/LF between rows but uses LF for multi-line cells and the value is in double-quotes.
printf '"line one\nline two"\r\nanother line' > foobar.csv