Converting a Postgresql database from SQL_ASCII, containing mixed encoging types, to UTF-8

后端 未结 4 690
没有蜡笔的小新
没有蜡笔的小新 2021-01-13 14:11

I have a postgresql database I would like to convert to UTF-8.

The problem is that it is currently SQL_ASCII, so hasn\'t been doing any kind of encoding conversion o

4条回答
  •  不要未来只要你来
    2021-01-13 14:43

    This is exactly the problem that Encoding::FixLatin was written to solve*.

    If you install the Perl module then you'll also get the fix_latin command-line utility which you can use like this:

    pg_restore -O dump_file | fix_latin | psql -d database
    

    Read of the 'Limitations' section of the documentation to understand how it works.

    [*] Note I'm assuming that when you say ISO-8859-x you mean ISO-8859-1 and when you say CP125x you mean CP1252 - because the mix of ASCII, UTF-8, Latin-1 and WinLatin-1 is a common case. But if you really do have a mixture of eastern and western encodings then sorry but you're screwed :-(

提交回复
热议问题