Re: Japanese with UTF-8 and mysql
| From: | Mark Sargent | Date: | Fri, 03 Jun 2005 05:08:51 +0000 |
| Subject: | Re: Japanese with UTF-8 and mysql | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-216296@lists.php.net to get a copy of this message | ||
Richard Davey wrote:
Hello Mark, Thursday, June 2, 2005, 4:18:30 AM, you wrote: MS> <?php MS> session_start(); MS> include("database.php"); ?>> I would recommend setting UTF-8 as the Content-type via PHP itself: header('Content-type: UTF-8') - do it as one of the first things when you're ready to output the HTML. Yes, have already tried it. No success.
MS> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" MS> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> This may well be a cause of the problem - your HTML doesn't look like it's XTHML Strict compatible at all, so browsers are going to re-render it (IE into Quirks mode). I would remove the DocType for now or fix the mark-up errors. Can't c that as it, as static J renders fine.
MS> <?php MS> if (isset($_REQUEST[product_id])) {MS> $product_id = $_REQUEST[product_id];See the previous reply about why this isn't safe, but also it should be: $_REQUEST['product_id'] (note the quotes) to avoid PHP scanning for constants. Ok, will look into that stuff a little more, once I get J rendering correctly.
MS> for ($i=0; $i<$num; $i++){ MS> echo "<tr align=\"center\"><td>PRODUCT MS> NAME</td><td>".$rows['product_name']."</td><br><tr From a code point of view this is correct. Let's check a few obvious things: does PHP have the mb extension installed? Yes, installed.
If so what is the default character-set in php.ini? Best regards, Richard Davey httpd.conf:AddDefaultCharset utf-8 AddCharset ISO-8859-1 .iso8859-1 .latin1 AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen AddCharset ISO-8859-3 .iso8859-3 .latin3 AddCharset ISO-8859-4 .iso8859-4 .latin4 AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk AddCharset ISO-2022-JP .iso2022-jp .jis AddCharset ISO-2022-KR .iso2022-kr .kis AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5 .Big5 .big5# For russian, more than one charset is used (depends on client, mostly): AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866 AddCharset KOI8-r .koi8-r .koi8-ru AddCharset KOI8-ru .koi8-uk .uaAddCharset ISO-10646-UCS-2 .ucs2 AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8 .utf8php.ini: output_handler = mb_output_handler ;; Set HTTP header charset
default_charset = UTF-8[mbstring] ; language for internal character representation. mbstring.language = Neutral ; internal/script encoding. ; Some encoding cannot work as internal encoding. ; (e.g. SJIS, BIG5, ISO-2022-*) mbstring.internal_encoding = UTF-8 ; http input encoding. mbstring.http_input = auto ; http output encoding. mb_output_handler must be ; registered as output buffer to function mbstring.http_output = UTF-8 ; enable automatic encoding translation accoding to ; mbstring.internal_encoding setting. Input chars are ; converted to internal encoding by setting this to On. ; Note: Do _not_ use automatic encoding translation for
; portable libs/applications.mbstring.encoding_translation = On ; automatic encoding detection order. ; auto means mbstring.detect_order = auto ; substitute_character used when character cannot be converted ; one from another mbstring.substitute_character = none Cheers. Mark Sargent.