Problem with utf8 encoding

Поиск
Список
Период
Сортировка
От Jorge Miranda Castañeda
Тема Problem with utf8 encoding
Дата
Msg-id 64de42ef0912022300kb4f989fgf34e98bf5d2a838f@mail.gmail.com
обсуждение исходный текст
Ответы Re: Problem with utf8 encoding  (Andrew McMillan <andrew@morphoss.com>)
Список 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.

В списке pgsql-php по дате отправления:

Предыдущее
От: Eric Chamberlain
Дата:
Сообщение: Re: Use of pg_escape_string()
Следующее
От: Andrew McMillan
Дата:
Сообщение: Re: Problem with utf8 encoding