Character encoding issue with PDO_ODBC
When running on Linux and using the FreeTDS driver, the charset for the client can be configured with the client charset
setting in the freetds.conf
file. In order for the freetds.conf
file to be used when using PDO ODBC and unixODBC, one needs to configure the ODBC datasource using ODBC-combined configuration. When ODBC-only configuration is used to configure the ODBC datasource, the file freetds.conf
is not used. With this I was able to retrieve and insert UTF-8 data from/into the MS SQL Server database.
Being a Linux/Unix guy, I was unable to understand/find a way how to configure the charset used when PDO ODBC is used on Windows. My vague understanding is that when configured at the system level, an ODBC datasource can be configured to use either de SQL Server database's charset or convert to the client computer charset.