Symfony2+Doctrine: How to convert iso8859-1 to utf-8 and viceversa?

后端 未结 2 1985
南笙
南笙 2021-01-20 21:40

We\'re building a Symfony2 app that\'s using an Oracle database. All the data in the DB is encoded as WE8ISO8859P15 (iso-8859-1), and all the website is encoded as utf-8.

2条回答
  •  伪装坚强ぢ
    2021-01-20 21:53

    You are able to set encoding of connection to your oracle db in config.yml. In your case you should set connection encoding to UTF-8 and Oracle should handle all conversion between UTF-8 (website) and iso-8859-1 (db) encoding. So putting this configuration in your config.yml should be enough:

    doctrine:
        dbal:
            default_connection: oracle
            connections:
                oracle:
                    driver:   %ora_database_driver%
                    host:     %ora_database_host%
                    port:     %ora_database_port%
                    dbname:   %ora_database_name%
                    user:     %ora_database_user%
                    password: %ora_database_password%
                    charset:  UTF8
    

提交回复
热议问题