dhtmlxgrid localisation problem

I have an UTF-8 table in a MySQL database that contains strings from different languages.
When I display these strings in a grid I get the � symbol in place of the special characters.

My grid is as follows:

and the Yii/PHP code is:

    public function actionGrid_data_translations()
            // grid processing and validation
            function beforeMessageInsert($action){
                $sourcemessageid = $_GET['sourcemessageid'];
            function beforeMessageUpdate($action){
                $sourcemessageid = $_GET['sourcemessageid'];
            // grid configuration
            $sourcemessageid = $_GET['sourcemessageid'];
            $languageoptions = Yii::app()->params['languages'];     
            $grid = new GridConnector($res, "MySQL");
            $config = new GridConfiguration();
                $header = Yii::t('translation','Language') . "," . Yii::t('translation','Translation');
            $grid->set_options("language", $languageoptions); 
            $sql = 'SELECT id, language, translation
                    FROM Message
                    WHERE SourceMessage_id = ' . $sourcemessageid  . '
                    ORDER BY language ASC';    
            if ($grid->is_select_mode())


The strings are displayed correctly in PHP/HTML, they are just wrong in the grid.

Any ideas? Thanks!

I think you need to surround the strings with cdata tag, i.e. .

I am not a PHP guy, but I believe it will help. For more info, you can check http://www.w3schools.com/xml/xml_cdata.asp

Thank you Sam but no, the problem is not solved with your suggestion (when I enclose the javascript code in CDATA tags the entire grid disappear).
There is no XML here, just some PHP code that reads strings from a MySQL table and displays the strings on a page.
When PHP displays the strings directly in HTML, the language characters (accented vowels, etc.) are displayed correctly, when it hands over the strings to the DHTMLX grid they are replaced with the black diamond with a question mark.
Funny enough i one of my grids one column, “language”, built with

$grid->set_options(“language”, $languageoptions);

is displayed correctly, the other one, “translation”, built via


is jumbled.

Unfortunately the issue cannot be reconstructed. Please, check your encoding settings.
If issue still occurs - please, provide a demo link where the issue can be reconstructed.

Thank you Sematik, I will try to provide a link.

OK, this is the link to test the problem.


Login as jamescaird/jamescaird

Navigate to the
System/Localisation/Maintain Language option
or to the
System/Localisation/Search Entries option and select the entry: Email (for example) and trigger the action Update Translations

FTP: jamescaird/jamescaird

Please, try to open the generated XML in the browser.
You can see the following error:
This page contains the following errors:
error on line 2 at column 57: Encoding error

Please, make sure that all characters in your xml accord to UTF-8 encoding type

Hi Sematic, thank you for your reply.

I am not sure though what I have to do.

  1. the Message table, that contains the data, has default character set = utf8 and default collation = utf8_general_ci
  2. if I look at the text with phpMyAdmin or with Navicat I see the text correctly displayed
  3. the text is displayed correctly by PHP in the application (try changing the language and check try to create a new User in the Administration menu and see that the text including accented characters is displayed correctly)
  4. the only problem occurs when the render_table or render_sql functions directly access the Message table; the error occurs in the HTML generated by your code

Please see the attached phpMyAdmin screenshots.

This is a show stopper, if I cannot solve this I won’t be able to use DHTMLX.

Shall I give up on this one?

I’m having exactly the same problem using the stock dhtmlxConnector_php_v15_120612 connected to a table using utf8_general_ci.

Any advice on this one as it’s a blocker to us adopting this product?

Cheers, Jonathan

After spending ages messing about with page encoding, setting uft-8 in the headers, I finally found a solution which works (for me at least). Add:

$dbh -> exec(“set names utf8”);

To you database code. This assumes you are using PHP and PDO.

Cheers, Jonathan

Thanks Jonathan, I will try this!

Yes, it does work! Thanks a lot!

I have solution if you’re not using PDO :

For grid - inside database code after $conn = new GridConnector($res,“MySQL”); use $conn->sql->query(“set names utf8”);

For form - inside database code after $form = new FormConnector($res); use $form->sql->query(“set names utf8”);