(Certains programmes du monde Windows ont tendance à générer cet encodage par défaut.)
Code : Tout sélectionner
malekalmorte@debian:/tmp$ file test.txt
test.txt: Little-endian UTF-16 Unicode text, with CRLF line terminators
Code : Tout sélectionner
malekalmorte@debian:/tmp$ cat test.txt |more
��ceci est une d�mo
Coin Coin <o_/
http
Code : Tout sélectionner
malekalmorte@debian:/tmp$ cat test.txt |grep http
malekalmorte@debian:/tmp$
Code : Tout sélectionner
malekalmorte@debian:/tmp$ uni2ascii test.txt
Invalid UTF-8 code encountered at byte 0, character 0.
malekalmorte@debian:/tmp$ !cat
cat test.txt |more
��ceci est une d�mo
Coin Coin <o_/
Solution :
La solution est de convertir le fichier en UTF-8, la commande iconv peut vous y aider.
Code : Tout sélectionner
alekalmorte@debian:/tmp$ iconv --from-code=UTF-16 --to-code=UTF-8 test.txt> test2.txt
malekalmorte@debian:/tmp$ cat test2.txt |grep http
http
malekalmorte@debian:/tmp$ file test2.txt
test2.txt: UTF-8 Unicode text, with CRLF line terminators
Code : Tout sélectionner
:set fileformat=unix
:set fenc=utf8
:wq
Vous pouvez alors réenregistrer le fichier depuis Windows dans un autre format (voir capture ci-dessous) :