neavilag
neavilag

Reputation: 609

Display thai characters on Page PHP / Thai chars ok in DB at server

I am trying to show Thai Characters in my app PHP / MySQL, data is being inserted from a backend process to the database and Thai chars are in the Database, but are not show in the front end. PHP.

I have tried with UTF-8 encoding in the page, and Windows-874

What is the right combination for this to be shown correct in the Browser? see image

enter image description here enter link to image bigger size thanks

Upvotes: 0

Views: 4686

Answers (2)

Pieter
Pieter

Reputation: 1774

To properly use UTF-8 within your web application, make sure that:

  1. the connection to the database is UTF-8. This can be set with mysql_set_charset, or, when you're not using ext/mysql, via the query SET NAMES utf8
  2. the varchar/text columns of your database tables uses a UTF-8 character set and collation
  3. when working with UTF-8 strings, you use php functions which support multibyte strings. The best solution would be to install the mbstring extension. If that is not possible, you can use the iconv functions.
  4. your http response headers include a UTF-8 header. This can be set using header('Content-Type: text/html;charset=utf-8');
  5. your html page includes a content-type meta tag: <meta name="Content-Type" content="text/html; charset=utf-8" />

Upvotes: 1

user1150525
user1150525

Reputation:

The site where you enter the text need to be utf-8 encoded and the table field.

Another thing which is often forgotten is to set

mysql_set_charset('utf8');

after opening the connection.

(And, of course, the frontend must be utf-8 encoded.)

Upvotes: 1

Related Questions