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
With the -zoption you can do
-z
sed -z 's/\n/\\n/g' file
or
sed -z "s/\n/\\\n/g" file