text file encoding shows correctly on terminal, not in editor

I got a problem with the encoding of a text file.

If I open it with *nix terminal tools like less, cat or more, accented characters are shown correctly. But if I open it with any editor (e.g. vim), accented characters are scrambled.

My terminal locale is set tu UTF-8, my editor (vim) has his default encoding set to UTF-8. If I open textfile.txt with vim I see scrambled accents either I set vim encoding to UTF-8 or ISO8859-1.

The output of the file utility is:

$ file textfile.txt
textfile.txt: ISO-8859 English text, with very long lines

I already tried the following with iconv:

iconv -f iso-8859-1 -t utf-8 textfile.txt > textfile.utf8.txt

I get this

$ file textfile.utf8.txt
textfile.utf8.txt: UTF-8 Unicode English text, with very long lines

Opening it with vim keeps showing scrambled accents, and this time accents are scrambled even if I use cat or more.

My goal is to get this file in UTF-8 format and, obviously, showing correctly the accented characters.

[The brute way to do this is to copy every single output screen of the command "more", and paste it into an editor. There must be a smarter way to do this.]

Thanks for any help.

Answers


It turned out that the file contained characters from two different encodings, that's why visualizations were so scrambled in every case, and iconv didn't manage to successfully convert the file. Thanks everyone anyway


Need Your Help

What happens when we refresh a web page?

asp.net refresh webpage

I was hoping if anyone can answer a fundamental question that I have regarding refreshing of a web page.

How to set QTableWidget background transparent in Qt?

qt background transparency qtablewidget

I am developing an app in which I am using QTableWidgets, and I need to set its background transparent, I have tried to setStyleSheet "background:transparent;" from form, but nothing happened, is t...