I just wanted to convert a txt file to UTF-8, since cat displays it correctly, but vi or gedit doesn't:

$ cat test.txt 
$ iconv -f WINDOWS-1253 -t UTF-8 test.txt 
β”iconv: illegal input sequence at position 18

Q: how can I convert my txt to UTF-8? iconv doesn't works.

  • 1
    Could you show us the output of file test.txt? Are you sure it's not already utf8?
    – terdon
    Commented Apr 22, 2014 at 11:36

2 Answers 2


Your file contains characters such as and which are not in Windows-1253, so whether the iconv fails or not, you did not specify the correct input encoding and therefore the output is wrong.

If cat displays the file correctly, then the file's encoding is the same as your terminal's. Run the command locale and look at the LC_CTYPE line to see what encoding your terminal is using. It's likely that the file is, in fact, already encoded in UTF-8.

It seems that Vi and Gedit are failing to detect the encoding of the file automatically. Have you configured them to assume a particular encoding? If so, don't do that. If not, in Gedit, select “UTF-8” instead of “automatically detected” when opening the file. In Vim, use :set encoding=utf-8.


The source characters look like it may be ATARI. Try -f ATARI or -f ATARIST

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .