I am using the PHP PDO_Informix driver v1.2.7 and the Informix client version is 3.70. I have some code in UTF-8 that makes queries to a Latin1 database (the Informix server is 9.21).
The thing is that the driver is chopping some values of the return strings. It's like special characters counts double. If a column 'name' has type varchar(2) and the value of name is 'áa' the value returned when queried is 'á' instead of 'áa'. If I resize the column to varchar(3) the result is correct. Below I attach a short script to reproduce the bug. I included the DSN so you can see the encoding settings.
Test script:
$dsn = "informix:database=base;server=ol_server;host=192.168.123.123;client_locale=en_us.utf8;db_locale=en_us.819;service=1526;protocol=olsoctcp;EnableScrollableCursors=1";
$db = new \PDO($dsn, 'user', 'pass');
$db->exec("CREATE TABLE ticket82 ( name VARCHAR(2) );");
$db->exec("INSERT INTO ticket82 VALUES ('aa');");
$statement = $db->query("select name from ticket82;");
$value = $statement->fetchAll(\PDO::FETCH_ASSOC);
echo "expected 'aa' got '{$value[0]['NAME']}'
";
$db->exec("update ticket82 set name='áa';");
$statement = $db->query("select name from ticket82;");
$value = $statement->fetchAll(\PDO::FETCH_ASSOC);
echo "expected 'áa' got '{$value[0]['NAME']}'
";
$db->exec("ALTER TABLE ticket82 MODIFY (name varchar(3));");
$statement = $db->query("select name from ticket82;");
$value = $statement->fetchAll(\PDO::FETCH_ASSOC);
echo "expected 'áa' got '{$value[0]['NAME']}'
";
$db->exec("DROP TABLE ticket82;");
Expected result:
expected 'aa' got 'aa'
expected 'áa' got 'áa'
expected 'áa' got 'áa'
Actual result:
expected 'aa' got 'aa'
expected 'áa' got 'á'
expected 'áa' got 'áa'
Any ideas?