In normal windows-to-unix conversion, you can do something like sed s/\r//g, which removes the \r characters from the stream.
But I'm trying to convert endlines of files that could be mac encoded (\r) or windows encoded (\r\n). So I cannot just remove the \r, as it would delete the mac endings if there's any. I have to "canonicalize" the line-ending characters first. This canonicalization step converts from \r\n to \r (after which I do the \r to \n conversion). Yet, I'm not able to solve this step with sed. I tried something like this:
$> echo -e "foo\r\nbar" | sed 's/\r\n/\r/g' | xxd -c 24 -g 1
00000000: 66 6f 6f 0d 0a 62 61 72 0a foo..bar.
I was able to solve it with bbe like this:
$> echo -e "foo\r\nbar" | bbe -e 's/\r\n/\r/g' | xxd -c 24 -g 1
00000000: 66 6f 6f 0d 62 61 72 0a foo.bar.
Is it possible to do the same with sed?