Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
Can you try this iconv -f cp850 -t utf-8 and check the file type – devav2 Aug 29 '12 at 10:10
@devav2: Why don't you post that as an answer, so I can accept it? =) I still have to manually fix failed conversions (again...), but I get a file with the right encoding afterwards. – Tomas Lycken Aug 29 '12 at 10:58
up vote 1 down vote accepted

Try iconv -f cp850 -t utf-8. Might help you

share|improve this answer
That did the trick! It still didn't convert all the characters correctly (but given the nonstandard encoding I started with, I doubt anything would...) so I had to manually correct that afterwards, but all the line endings are correct now. Thanks! – Tomas Lycken Aug 29 '12 at 12:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.