开发者

How can I convert Cyrillic stored as LATIN1 ( sql ) to true UTF8 Cyrillic with iconv?

开发者 https://www.devze.com 2022-12-22 16:47 出处:网络
I have a SQL dump file consisting of incorrectly stored Cyrillic Russian ( WINDOWS-1251 ) text, example Èðàíñêèå which should properly be displayed as Иранские.

I have a SQL dump file consisting of incorrectly stored Cyrillic Russian ( WINDOWS-1251 ) text, example Èðàíñêèå which should properly be displayed as Иранские.

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

Logically it would make s开发者_如何学Cense that since it's 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've tried:

1.

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

Output:

Èðàíñêèå ( Not what I want )

2.

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

Output:

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

Notes

  • It's possible that I might have converted once and then twice to get my desired result, but I'm pretty sure that on the last step I converted from WINDOWS-1251 to UTF-8//TRANSLIT as that was written down in my notes.

  • One other note is that I'm viewing Èðàíñêèå in the SQL file when the file encoding is utf8 ( native in vim ). If I do set enc=latin1 in vim then I see ~Hð| íñêèå as if that doesn't make it more confusing.


iconv -f utf-8 -t latin1 < in.sql | iconv -f cp1251 -t utf-8 > out.sql
0

精彩评论

暂无评论...
验证码 换一张
取 消