I have WIN1257 Firebird database which I am trying to use with Yii extension. That technically works, but there are problems with encoding. Specifically - REST GET request gives error when varchar fields contain non-latin symbols:
{
"name": "Exception",
"message": "Malformed UTF-8 characters, possibly incorrectly encoded.",
"code": 5,
"type": "yii\\base\\InvalidParamException",
"file": "C:\\xampp\\htdocs\\myproject\\vendor\\yiisoft\\yii2\\helpers\\BaseJson.php",
"line": 123,
"stack-trace": [
"#0 C:\\xampp\\htdocs\\myproject\\vendor\\yiisoft\\yii2\\helpers\\BaseJson.php(61): yii\\helpers\\BaseJson::handleJsonError(5)",
"#1 C:\\xampp\\htdocs\\myproject\\vendor\\yiisoft\\yii2\\web\\JsonResponseFormatter.php(89): yii\\helpers\\BaseJson::encode(Array, 320)",
"#2 C:\\xampp\\htdocs\\myproject\\vendor\\yiisoft\\yii2\\web\\JsonResponseFormatter.php(73): yii\\web\\JsonResponseFormatter->formatJson(Object(yii\\web\\Response))",
"#3 C:\\xampp\\htdocs\\myproject\\vendor\\yiisoft\\yii2\\web\\Response.php(948): yii\\web\\JsonResponseFormatter->format(Object(yii\\web\\Response))",
"#4 C:\\xampp\\htdocs\\myproject\\vendor\\yiisoft\\yii2\\web\\Response.php(312): yii\\web\\Response->prepare()",
"#5 C:\\xampp\\htdocs\\myproject\\vendor\\yiisoft\\yii2\\base\\Application.php(381): yii\\web\\Response->send()",
"#6 C:\\xampp\\htdocs\\myproject\\web\\index.php(12): yii\\base\\Application->run()",
"#7 {main}"
]
}
So - the question is - is there possible to extend some class and to make WIN1257-Unicode conversion when data are read from database and make Unicode-WIN1257 conversion before data are saved to database. I guess that large parts of the Yii can handle non-Unicode data but REST-JSON requires all the data to be in Unicode format.