Crozarius Posted April 26, 2010 Share Posted April 26, 2010 I have been trying to figure out how to get my PHP script to display Japanese characters correctly. Whenever the array containing the characters is out put, they show up as ?? Ex: Array ( [number] => 5414 [katahira] => ?? [romaji] => neko [kanji] => ? [definition] => cat [kanji pronunciation] => ?…?? ) ?? The characters show up correctly on my Mysql web interface fine. They are entered as: Type: tinytext Collation: utf8_unicode_ci I have looked over a lot of pages, but the fixes are not working for me. Anyways, here is my code: <?php header('Content-Type: text/html;charset= utf8_unicode_ci'); $databaseName = bc1253;// database that is used // connects to the database $connection = mysql_connect("*******", "*********", "**********"); mysql_select_db($databaseName, $connection); // searches the data base and returns the row the object is found in. $result = mysql_query("SELECT * FROM Japanese WHERE Romaji = '$_POST[Word]'") or die("broken"); // Puts row of results in an array $outPut = mysql_fetch_array($result, MYSQL_ASSOC); Print_r($outPut); ?> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/199842-japanese-text/ Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 I've worked with Japanese text in php before. You need to make sure the php file is encoded as UTF-8, a header alone will not make it work. In Notepad++ you can do it like this: Link to comment https://forums.phpfreaks.com/topic/199842-japanese-text/#findComment-1048957 Share on other sites More sharing options...
khr2003 Posted April 26, 2010 Share Posted April 26, 2010 actually, you have to select "convert to UTF-8 without BOM" in notepad++ and save the file in order to display the characters correctly in your browser. "Encode in UTF-8 Without BOM" will only change the display in the file view. Additioanlly, you browser encoding has to bet set to utf-8 as well. Link to comment https://forums.phpfreaks.com/topic/199842-japanese-text/#findComment-1049021 Share on other sites More sharing options...
Crozarius Posted April 27, 2010 Author Share Posted April 27, 2010 I had the original .csv saved in just UTF-8, not UTF-8 without BOM. After re-loading it in UTF-8 without BOM and fixing the header, It worked great.Thanks a ton Link to comment https://forums.phpfreaks.com/topic/199842-japanese-text/#findComment-1049102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.