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