Johi
Johi

Reputation: 31

Doctrine2 with Symfony2 not recognizing db charset and collation

I am trying to get Doctrine2 to work properly with a mysql db in Symfony2 on a debian squeeze system. The charset and collation of the DB are set to utf8 and utf8_general_ci and the db is created manually by reading in an sql script.

Now I enter some values for one of the tables with danish special chars like æøå and they simply wont display correctly.

My parameters.yml has set encoding: utf8 and in my config.yml the doctrine configuration has:

doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8

When I do a select in the mysql console, the characters display correctly and also if I try by replacing the output array in the controller by som hardcoded values, so the problem seems definately to stem from some kind of error/bug in doctrine2 configuration...

Does anybody have any clues on how to solve this?

Thanks a lot.

Upvotes: 1

Views: 4062

Answers (2)

Johi
Johi

Reputation: 31

Ok I finally figured it out... there is some kind of double encoding going on with this configuration. Commenting out charset: UTF8 from doctrine dbal config solves the problem.

Upvotes: 2

Laurynas Mališauskas
Laurynas Mališauskas

Reputation: 1919

the problem might be in your application charset. it can be found in config.yml

framework:
  charset:         UTF-8
  #translator:      { fallback: lt }
  #secret:          %secret%
  #other options

Upvotes: 0

Related Questions