I am trying to convert to unicode and create some unit tests to ensure unicode is working.
Here is my current code that crashes in the mb_detect_encoding () line, and which I am also not sure if it is a valid unicode support test:
function testMultiLingualEncodings(){
$original = '
A good day, World!
Schönen Tag, Welt!
Une bonne journée, tout le monde!
يوم جيد، العالم
좋은 일, 세계!
Một ngày tốt lành, thế giới!
こんにちは、世界!
';
$this->assertTrue(mb_detect_encoding($original, 'UTF-8', true) === true);
$returned = query_item("select :multi limit 10", array(':multi'=>$original));
$this->assertTrue((bool)$original);
$this->assertTrue((bool)$returned);
$this->assertTrue($original === $returned);
}
So mb_detect_encoding () says the start line above is not UTF-8. I am also trying to pass this string to the database and get it, and then compare with the original string. However, I'm not sure if this is a valid test for encoding a database connection.
In general, how can I create unit test support for utf-8, and the method is higher than what can be changed to solve this?
Kzqai