Error :
QLSTATE[HY000]: General error: 20018 Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.
Diagnosis:
The requisite encoding UTF-8 is not getting set.
Application Stack:
MS SQL
YII framework
PHP
Red Hat
Fixes at all levels of application stack:
1. MSSQL – Checked at the database level, SQL data is getting stored and retrieved without any issues.
2. YII – ini_set(‘mssql.charset’, ‘UTF-8’); in index.php
3. PHP – in /etc/php.ini,
default_charset = “UTF-8”
mssql.charset = “UTF-8”
4. Red Hat Server
In /etc/freetds.conf –
ensure in teh global settings if dedicated server else have a separate section with these setting for your application instance
[global]
host = servername
client charset = UTF-8
tds version = 8.0
text size = 20971520
References:
– http://www.yiiframework.com/wiki/16/how-to-set-up-unicode/
– Basics: http://blog.goosoftware.co.uk/2012/12/05/how-ascii-lost-and-unicode-won/
– http://stackoverflow.com/questions/1322421/php-sql-server-how-to-set-charset-for-connection
– http://www.craig-edmonds.com/solved-php-mssql-unicode-encoding-issues/