|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-07-10 21:51 UTC] sniper@php.net
[2007-07-12 07:00 UTC] jhala at uoregon dot edu
[2007-07-12 09:00 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 07:00:01 2025 UTC |
Description: ------------ I have a fully UTF-8 MySQL database with a fully UTF-8 table. I have a php page which has "<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />" at the top of the html section and "mysql_set_charset("utf8");" after my connection. I have all my php.ini mbstring stuff configured for utf-8: mbstring.language = Neutral mbstring.internal_encoding = UTF-8 mbstring.http_input = auto mbstring.encoding_translation = On mbstring.detect_order = auto and for what it's worth, echo mb_internal_encoding(); reports "UTF-8" and mysql_client_encoding(); reports "utf8". Reproduce code: --------------- $con = mysql_connect('localhost', 'user', 'password'); mysql_select_db("database", $con); mysql_set_charset("utf8"); $query = "SELECT japanese_terms.term_lang, language_en FROM japanese_terms, languages "; $query .="WHERE japanese_terms.term_id = languages.language_id ORDER BY term_id"; $result = mysql_query($query); while( $row = mysql_fetch_row($result)) { foreach($row as $field) { print($field . "<br />"); } } Expected result: ---------------- I expect the UTF-8 data to display properly, and as UTF-8 data. When I run the same query that pulls out (in this case, Japanese, but say any) UTF8 data, it displays properly in MySQL Query Browser. Actual result: -------------- With php in the above context however, it does not. Instead, it prints a ? corresponding to each character. When I use mb_detect_encoding(); on each such string, it tells me they are encoded as "ASCII" instead of expected "UTF-8".