Problem with utf8 encoding

From: Jorge Miranda Castañeda <jmirandac(dot)85(at)gmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: Problem with utf8 encoding
Date: 2009-12-03 07:00:16
Message-ID: 64de42ef0912022300kb4f989fgf34e98bf5d2a838f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hello everyone!

I'm working in a project using postgres, propel, and php.

My development environment is:
SO: Windows vista Business SP2
Postgres: Postgres v8.4
Propel: Propel generator/runtime v1.4
PHP: PHP v5.3

Currently I'm struggling with a problem caused by the encoding. Everytime I
try to insert a row into the table CURRENCY, which has ID, DESC, and SYMBOL
as its columns, I get the following error:
Unable to execute INSERT statement. [wrapped: SQLSTATE[22021]: Character not
in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0x80
HINT: This error can also happen if the byte sequence does not match the
encoding expected by the server, which is controlled by "client_encoding".]

I've created the database using this sentence:
*CREATE DATABASE sbs*
* WITH OWNER = sbsadmin*
* ENCODING = 'UTF8'*
* LC_COLLATE = 'Spanish_Peru.1252'*
* LC_CTYPE = 'Spanish_Peru.1252'*
* CONNECTION LIMIT = -1;*

When I run the following commands in psql I get this:
*sbs=#SHOW SERVER_ENCODING;*
*server_encoding*
*---------------*
*UTF8*
*(1 fila)*

*sbs=#SHOW CLIENT_ENCODING;*
*client_encoding*
*---------------*
*UTF8*
*(1 fila)*

The generated file by propel that manages the database connection sets the
charset to utf8 too. The insertion fails only everytime I try to insert the
currency symbols such as €, ¥, £, ₱, etc. I have no problem with symbols
such S/., $, p., Q, L or any other non-special symbol. The curious thing is
that when I run the sentence INSERT INTO CURRENCY VALUES(3,'EURO','€');
using the query tool of pgAdminIII, I got no error and the query was
sucessfully executed. However running the same sentence in psql, I got the
row inserted but with ? instead of € as the currency symbol.
I think the utf8 is the apropiate charset to represent these symbols but I
have no idea why I'm getting this problem. I've spent the whole day
struggling with this problem and I can't figure it out yet. I have tried
many things, none of them worked. So this is why I'm here asking for your
help, as my last resource. Any guidance that could put me in the right
direction to address this problem will be really appreciated!

Thanks in advance and I'm sorry If I went on a bit long...

--
Jorge Miranda Castañeda.
Simbiosys Software S.A.C.
www.simbiosysonline.com

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Andrew McMillan 2009-12-03 09:35:14 Re: Problem with utf8 encoding
Previous Message Eric Chamberlain 2009-11-23 17:31:24 Re: Use of pg_escape_string()