This stackoverflow question has an answer to replace newlines with sed, using the format sed \':a;N;$!ba;s/\\n/ /g\'.
This works, but not for special characters like
You could do this using sed and tr:
sed
tr
sed 's/$/\\n/' file | tr -d '\n'
However this will add an extra \n at the end.
\n