Display Non-English Characters

If database is created in charset other than default charset, e.g. “latin1″, some characters may be displayed as “?” in the grid. To properly display non-English characters, such as Spanish, Fresh, or Chinese, in MySQL, PostgreSQL, and Oracle you can define the character set value in ‘DB_CHARSET’ variable in conf.php.

In conf.php, set the DB_CHARSET to the corresponding charsets in your database.

version 6+ (with “PHPGRID_” prefix):

1
2
3
4
5
6
define('PHPGRID_DB_HOSTNAME','hostname'); // database host name
define('PHPGRID_DB_USERNAME', 'username'); // database user name
define('PHPGRID_DB_PASSWORD', 'password'); // database password
define('PHPGRID_DB_NAME', 'sampledb'); // database name
define('PHPGRID_DB_TYPE', 'mysql'); // database type
define('PHPGRID_DB_CHARSET','utf8'); // OPTIONAL. Leave blank to use the default charset

version 5.5.x and below:

1
2
3
4
5
6
define('DB_HOSTNAME','hostname'); // database host name
define('DB_USERNAME', 'username'); // database user name
define('DB_PASSWORD', 'password'); // database password
define('DB_NAME', 'sampledb'); // database name
define('DB_TYPE', 'mysql'); // database type
define('DB_CHARSET','utf8'); // OPTIONAL. Leave blank to use the default charset

Add the Meta element to the HTML head node and set character encoding to UTF-8. Note it’s important that the actual file must also be saved as UTF-8 encoding.

1
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

 

Dealing with Special Characters in SQL Server with Non-English Collation

It is slightly more complicated when using SQL Server collation other than the default English-language (US) “SQL_Latin1_General“, you may have trouble display those non-English characters such as “Löi, cé”.

The methods below is also available on KB. It demonstrate how to display Chinese (BIG5) characters from SQL Server.

In data.php, near line 213 change the following from

1
$data[] = $row[$col_name];

to

1
$data[] = iconv("BIG5", "UTF-8", $row[$col_name]);

– OR –

1
$data[] = mb_convert_encoding($row[$col_name], "UTF-8", "BIG5");

Also in the same file, below comment
“// ******************* execute query finally *****************”

Add the following line

1
$SQL = iconv("UTF-8","BIG5",$SQL);

 

Foreign Characters in PDF export

To export Chinese or other foreign characters, see KB: PDF can not display Chinese character
 

See Live Example!