Req #45864 [Opn->Csd]: wish: fwrite to support direct output of bytes (not cast to string)
| From: | php at richardneill dot org | Date: | Thu, 09 Jul 2015 22:26:43 +0000 |
| Subject: | Req #45864 [Opn->Csd]: wish: fwrite to support direct output of bytes (not cast to string) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194268@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=45864&edit=1
ID: 45864
User updated by: php at richardneill dot org
Reported by: php at richardneill dot org
Summary: wish: fwrite to support direct output of bytes (not
cast to string)
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: *General Issues
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
I the person who originally wrote this request, I think my 7-year-ago self didn't know enough C
to really realise what I was talking about. The pack() answer is clearly a better solution. Thanks
for your time, and please feel free to close this as wontfix.
Previous Comments:
------------------------------------------------------------------------
[2015-07-07 22:33:53] cmb@php.net
That seems too low-level to me. As PHP strings may contain
arbitrary bytes, you can easily build up the desired output
string(s) with pack('c*', ...) and write this/these to the file.
------------------------------------------------------------------------
[2008-08-19 15:50:44] php at richardneill dot org
Description:
------------
fwrite() outputs to file as a string. While this is usually a
sensible default, it can be rather annoying when I actually want to
output raw data. I know about using chr(), but that's ugly at least.
My request: add an option to fwrite that lets you output a char,
rather than a string.
[The chr() workaround is also not very visibly documented].
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=45864&edit=1