I've just got a db in postgreSQL for my project and just realized it's in SQL_ASCII encoding, which means "no encoding" I think.
So what is the simplest way to convert this to utf8? And I know the db should be in latin1, does the conversion will damage the content?
Thanks!
Converting to UTF8 should not damage your data as (I believe) all characters in SQL_ASCII also exist in utf8; they just have different byte codes.
Your best bet is to re-build your database. That is dump it, create a utf8 database then restore the dump to that new database.
You can then of course rename the databases once you are happy that the new UTF8 one matches your data.
UTF-8 conversion is all about what kind of characters where saved in the non UTF-8 db: depending on the data the proposed solution may fail. I managed to convert mine following this tutorial, using recode (a small tool from the GNU project that let you change on-the-fly the encoding of a given file) and I came up with this:
I resolved using these commands;
1-) Export
and after
2-) Import
these commands helped me solve the problem of conversion SQL_ASCII - UTF-8
I searched the entire internet looking for a solution to this issue and Koyots solution above worked first time after wasting countless hours trying everything to migrate an old SQL_ASCII database to a new UTF8 database
To expand upon the solution...
I'd suggest keeping both databases for a couple of weeks until you are sure you have not lost any data (provided you can spare the disk space)