Reputation: 13
I have a Postgres 8.2 database.
The table encode : SQL-ASCII. (I can't change this :( )
Xhtml charset: charset=iso-8859-2.
The files encode is ANSII. (notepad++)
When I show retrieved data with AJAX (jQuery) I must use utf8_encode(). When this data, insert into database, instead of accent letters (öüőűú) I see this &# 245; &# 251; and others.
Question: How can I solve this encode problem?
EDIT This work me:
pg_dump -E LATIN9 alt > alt.sql
createdb -T template0 -E UTF8 new_database
psql -f alt.sql new_database
Upvotes: 1
Views: 889
Reputation: 78413
I sounds like you're mixing utf8 encoding and html/xml escaping.
To reconfigure the database's encoding setting, the relevant bits say:
The default character set is selected while initializing your PostgreSQL database cluster using initdb. It can be overridden when you create a database, so you can have multiple databases each with a different character set.
CREATE DATABASE name
[ [ WITH ] [ OWNER [=] dbowner ]
[ TEMPLATE [=] template ]
[ ENCODING [=] encoding ]
[ TABLESPACE [=] tablespace ]
[ CONNECTION LIMIT [=] connlimit ] ]
Edit: per horse's name, you cannot alter the database's encoding, so you may need to dump the schema and data, edit the dump accordingly, and re-create it accordingly.
Upvotes: 1