Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29142 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7324 invoked by uid 1010); 3 May 2007 11:31:03 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 7308 invoked from network); 3 May 2007 11:31:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 May 2007 11:31:02 -0000 Authentication-Results: pb1.pair.com header.from=tokul@users.sourceforge.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=tokul@users.sourceforge.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain users.sourceforge.net from 213.197.162.99 cause and error) X-PHP-List-Original-Sender: tokul@users.sourceforge.net X-Host-Fingerprint: 213.197.162.99 avilys.eik.lt Linux 2.6 Received: from [213.197.162.99] ([213.197.162.99:56585] helo=avilys.eik.lt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/00-07047-AE7C9364 for ; Thu, 03 May 2007 07:30:53 -0400 Received: from avilys.eik.lt (avilys.local [127.0.0.1]) by avilys.eik.lt (Postfix) with ESMTP id E0D241F5148; Thu, 3 May 2007 14:29:30 +0300 (EEST) Received: from avilys.eik.lt (avilys.local [127.0.0.1]) by avilys.eik.lt (Postfix) with ESMTP id BDCFF1F5147; Thu, 3 May 2007 14:29:30 +0300 (EEST) Received: from 195.22.180.233 (NaSMail authenticated user tomas@topolis.lt) by avilys.eik.lt with HTTP; Thu, 3 May 2007 14:29:30 +0300 (EEST) Message-ID: <49539.195.22.180.233.1178191770.squirrel@avilys.eik.lt> In-Reply-To: <006c01c78d26$beda26f0$0301a8c0@rangeldc> References: <006c01c78d26$beda26f0$0301a8c0@rangeldc> Date: Thu, 3 May 2007 14:29:30 +0300 (EEST) To: "Rangel Reale" Cc: internals@lists.php.net User-Agent: NaSMail/1.0 MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: [PHP-DEV] Trying to understand PHP6's unicode support From: tokul@users.sourceforge.net ("Tomas Kuliavas") > Hello! > > I am trying to understand how PHP6 handling of unicode works, I think I am > missing something. > > My config is: > > ;;;;;;;;;;;;;;;;;;;; > ; Unicode settings ; > ;;;;;;;;;;;;;;;;;;;; > > unicode.semantics = on > unicode.runtime_encoding = iso-8859-1 > unicode.script_encoding = iso-8859-1 > unicode.output_encoding = utf-8 > unicode.from_error_mode = U_INVALID_SUBSTITUTE > unicode.from_error_subst_char = 3f > unicode.fallback_encoding = iso-8859-1 > > I use a mysql database, with iso-8859-1 (Portuguese - latin 1) text, with > accented characters. > > What I was trying to understand was, because unicode.runtime_encoding = > iso-8859-1, I tought that all internal operations were done in this > encoding, and only when outputting (unicode.output_encoding = utf-8) data > would be converted to utf-8. So to me, I did a mysql query with latin1, > data > comes to my variables as iso-8859-1, I use them, and only when I echo'ed > them, they would become utf-8, from a iso-8859-1-to-utf-8-like function. > > But when I do query in any record that have accented characters I get this > warning (using mysql_fetch_assoc): > > ---------- > Could not convert binary string to Unicode string (converter UTF-8 failed > on > bytes (0xE7) at offset 9) > ---------- > > for all accented characters in all fields. > > The strange thing to me, is the mysql_fetch_assoc function give this error > even before I accessed the field values, as I understanded from the above > explanation. > > If I changed the set names query to: > > mysql_query('set names utf8', $this->mysql_link); > > then it works, but I would like to understand how this works, to make my > program the right way from the start. > > Did I misundertood something? I think you are confusing PHP features with MySQL features. By running 'SET NAMES' query you set client, connection and result character sets in MySQL (see http://dev.mysql.com/doc/refman/4.1/en/charset.html). It is not related to PHP. MySQL has internal character set support since 4.1 version. -- Tomas