0

I'm from Czech republic and I have a problem with decode, I imported the product database to MYSQL, the products names is stored in a database using code ( probably UTF-8) . In php I used html_entity_decode() to decode, but is problably wrong coding. Anyone have idea? Thank you. For examples:

112 111 109 101 114 97 110 269 101 32 115 237 116.... -> "pomeran e sít 1k"

instead of

"pomeranče síť 1k"

and

80 114 97 382 115 107 225 32 48 46 53 108 -> Pra~ská 0.5

instead of

"Pražská 0.5"

SuperDJ
  • 7,488
  • 11
  • 40
  • 74
  • There are many considerations - the MySQL client connection encoding, the table character set (probably correct already) and the output encoding in PHP - you should not need `html_entity_decode()` because the values are probably not entity encoded in the database. [There are several things to look through here](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through-mysql-php-and-html/279279#279279) and also [over here](https://stackoverflow.com/questions/1317152/am-i-correctly-supporting-utf-8-in-my-php-apps) – Michael Berkowski Dec 25 '15 at 13:34
  • Your issue may be as simple as an incorrect output encoding on the HTML http://stackoverflow.com/questions/905173/how-do-i-set-character-encoding-to-utf-8-for-default-html – Michael Berkowski Dec 25 '15 at 13:35
  • I tried add header('Content-type: text/html; charset=utf-8'), the only change is display �.But When i tried used javascript method String.fromCharCode(), the decode is correcly. – robertnovak Dec 25 '15 at 13:47
  • Use mysql charset function – devpro Dec 25 '15 at 14:56

1 Answers1

0

After MYSQL connection you must need to select MYSQL charset function as like:

$link = mysql_connect('localhost', 'user', 'password');
mysql_set_charset('utf8',$link); // you need this
devpro
  • 16,184
  • 3
  • 27
  • 38