Replacing LF, NEL line endings in text file with CR+LF

Posted by Tomas Lycken on Ask Ubuntu See other posts from Ask Ubuntu or by Tomas Lycken
Published on 2012-08-29T09:05:45Z Indexed on 2012/08/29 9:50 UTC
Read the original article Hit count: 297

Filed under:
|

I have a text file with a strange character encoding that I'd like to convert to standard UTF-8. I have managed to get part of the way:

$ file myfile.txt
myfile.txt:        Non-ISO extended-ASCII text, with LF, NEL line endings
$ iconv -f ascii -t utf-8 myfile.txt > myfile.txt.utf8
$ file myfile.txt.utf8
myfile.txt.utf8:   UTF-8 Unicode text, with LF, NEL line endings

## edit myfile.txt.utf8 using nano, to fix failed character conversions (mostly åäö)

$ file myfile.txt.utf8
myfile.txt.utf8:   UTF-8 Unicode text, with LF, NEL line endings

However, I can't figure out how to convert the line endings. How do I do to replace LF+NEL with CR+LF (or whatever is the standard)? When I'm done, I'd like to see the following:

$ file myfile.txt
myfile.txt:        UTF-8 Unicode text

© Ask Ubuntu or respective owner

Related posts about encoding

Related posts about line-endings