0

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.

evachristine
  • 2,613

2 Answers2

1

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.

1

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