Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
1  
Could you show us the output of file test.txt? Are you sure it's not already utf8? –  terdon Apr 22 at 11:36

1 Answer 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.

share|improve this answer

Your Answer

 
discard

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.