Replace the inline sed commands with sed scripts to avoid the subshells
on Windows. Additionally, the unicode handling on Windows causes
problems and using the scripts circumvents that problem.
Implement an inline dos2unix as the BSD sed does not support `-b` and on
Windows, sed will convert the line endings.