Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:17808 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70255 invoked by uid 1010); 10 Aug 2005 20:13:02 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 70240 invoked from network); 10 Aug 2005 20:13:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Aug 2005 20:13:02 -0000 X-Host-Fingerprint: 216.145.54.171 mrout1.yahoo.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from ([216.145.54.171:24411] helo=mrout1.yahoo.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id F8/83-24081-DCF5AF24 for ; Wed, 10 Aug 2005 16:13:01 -0400 Received: from [66.228.175.145] (borndress-lm.corp.yahoo.com [66.228.175.145]) by mrout1.yahoo.com (8.13.4/8.13.4/y.out) with ESMTP id j7AKAV8k015651; Wed, 10 Aug 2005 13:10:31 -0700 (PDT) In-Reply-To: <1B.49.24081.1DAD9F24@pb1.pair.com> References: <937066F0-AA5F-41E2-99A0-D74C7F44FFCA@gravitonic.com> <1B.49.24081.1DAD9F24@pb1.pair.com> Mime-Version: 1.0 (Apple Message framework v622) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-ID: <7de4987954a7cf7643ae8e202bc5fe38@gravitonic.com> Content-Transfer-Encoding: 7bit Cc: internals@lists.php.net Date: Wed, 10 Aug 2005 13:10:29 -0700 To: "Ron Korving" X-Mailer: Apple Mail (2.622) Subject: Re: [PHP-DEV] Re: PHP Unicode support design document From: andrei@gravitonic.com (Andrei Zmievski) On Aug 10, 2005, at 3:45 AM, Ron Korving wrote: > This looks very promising, I'm impressed by the work you guys have > done (big > thumbs up). Thanks. > What about the other functions that output to stdout directly, such as > readfile() and passthru()? readfile() uses streams so it would rely on stream filters and such. passthru() should probably operate in binary mode. > Maybe it would be a nice feature to have an U_INVALID_EXCEPTION, so > that > users can actually catch the error and deal with it. Just an idea. Of > course > it's not usual for the PHP core and extensions to throw exceptions, but > perhaps this could change with PHP6. I think the feature of raising exceptions vs. errors is orthogonal to what the switch does. Consider that you may want the skip/substitute/escape performed and then raise an error or not. > The b-prefix for binary strings is great, but how does that work with a > function like file_get_contents() or fread() ? > One can't do: $data = bfile_get_contents("somefile.bin"); > And even if one could (somehow), wouldn't file_get_contents() already > unicode-encode all data it reads? How does such a function know if the > user > is expecting binary or textual data or does the encoding simply happen > after > the string is returned? In that case it's up to the user to use the > b-prefix, but then there's the syntax problem I mentioned. 'b' prefix is only for string literals. file_get_contents(), fread() and other streams-based functions use the default stream semantics, meaning that unless you change the default context, the data returned by them will be of IS_BINARY type. The default context can contain a filter that decodes the data from the specified encoding into Unicode. -Andrei