Propel / Sybase shows accents as squares

540 views Asked by At

I am using the ORM Propel to interact with my Sybase ASE 15.7 database from a Zend Framework webapp. When I do sp_helpsort my Sybase server seems to be using Latin-1 encoding.

I am realising that the accents that are in my database (which shows properly when I connect via a client like Toad for Sybase) show as squares on my web pages. If I pass such data through a JSON object, the string completely disappears and becomes null if it has accents. All the JSON objects are set up with a UTF-8 charset (returned with content-type application/json;charset=utf-8).

I tried to fix the issue by changing the character set and sort order of my server to UTF-8 and now sp_helpsort clearly shows it is using UTF-8 :

Sort Order Description


Character Set = 190, utf8 Unicode 3.1 UTF-8 Character Set Class 2 Character Set Sort Order = 25, binary Binary ordering for UTF-16 (return status = 0)

I tried again, using new data to make sure I don't use former Latin1 encoding text and I still have the same issue.

How can I ensure that the data are recovered properly and won't be affected if I pass them through a JSON object set up with UTF-8?

Thank you in advance for your advice.

1

There are 1 answers

0
mentinet On

I found a solution to my problem. The issue seems to be caused by the driver that I use to connect to my Sybase database : ODBC. The thing is to tell ODBC that it is using UTF-8 on the client side, so that Sybase can then convert content before returning it, if it uses another character set.

I managed to get the accents to show by adding these parameters to my ODBC connection string: Charset=utf8;KeepOrgMultibyte=1;

Sources: https://groups.google.com/d/msg/f3-framework/o5dvvsMCR4c/4-b0ZoSFWKgJ