How can I convert the Cyrillic alphabet saved as LATIN1 (sql) to the real UTF8 Cyrillic alphabet with an icon?

I have an SQL dump file consisting of incorrectly saved Russian Cyrillic text (WINDOWS-1251), an example Èðàíñêèå that should be displayed as .

In the past, I successfully converted the sql file, but the memory failed in what I did and in what order.

Logically, it would be reasonable that since it is stored in LATIN1, I would convert from LATIN1 to WINDOWS-1251, and then from WINDOWS-1251 to UTF-8 // TRANSLIT or something like that.

So far I have tried:

1.

 iconv -f WINDOWS-1251 -t UTF-8//TRANSLIT -o new.sql snippet.sql 

Conclusion:

€° ±ЄҐ (Not what I want)

2.

 iconv -f LATIN1 -t UTF-8//TRANSLIT -o new.sql snippet.sql 

Conclusion:

Ã<88>ðà Ãñêèå (Not what I want)

Notes

  • Maybe I could convert once and then twice to get the desired result, but I'm sure that in the last step I converted from WINDOWS-1251 to UTF-8//TRANSLIT , as it was recorded in my notes.

  • One more note: viewing the file in the SQL file when the encoding of the file is utf8 (native in vim). If I do set enc=latin1 in vim, then I see ~Hð| íñêèå ~Hð| íñêèå , as if this does not make him more confused.

+4
source share
1 answer
 iconv -f utf-8 -t latin1 < in.sql | iconv -f cp1251 -t utf-8 > out.sql 
+5
source

Source: https://habr.com/ru/post/1303391/


All Articles