# fwrite( ) gives Notice with Unicode ON

- Thread: https://externals.io/message/29998
- Original archive: https://news-web.php.net/php.internals/29998
- Started by Nikhil Gupta on 2007-05-31T12:38:50+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #29998 — Nikhil Gupta — 2007-05-31T12:38:50+00:00

URL: https://externals.io/message/29998#29998

Hi,
I'm writing some PHPT test cases for PHP 6 and wanted to check that I was seeing the correct behaviour with unicode.
I tried the following simple testcase and gets Notice message with php6 unicode ON.

--TEST--
test.phpt
--FILE--
<?php
$fh = fopen ("tempfile.tmp", "w" );
fwrite( $fh, "Sample text" );
fclose( $fh );
?>
--UEXPECT--

command:
php run-tests.php -u test.phpt
cat test.u.out

Following Notice is displayed:
Notice: `fwrite()`: 11 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d

There in no notice message with PHP6 unicode OFF, please would you confirm that the additional notices with Unicode on are intended? I think it will result in a large number of additional Notices if we use fwrite in a for loop.
 
Thanks & Regards
Nikhil


      ____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7

---

## #29999 — johannes@php.net — 2007-05-31T13:18:43+00:00

URL: https://externals.io/message/29998#29999 · In reply to: #29998

Hi,

yes, the notice is expected. You either have to cast to a binary string
or by setting the stream's encoding using stream_encode() since we can't
guess which encoding you're going to use for a stream.

johannes


> Hi,
> I'm writing some PHPT test cases for PHP 6 and wanted to check that I was seeing the correct behaviour with unicode.
> I tried the following simple testcase and gets Notice message with php6 unicode ON.
> 
> --TEST--
> test.phpt
> --FILE--
> <?php
> $fh = fopen ("tempfile.tmp", "w" );
> fwrite( $fh, "Sample text" );
> fclose( $fh );
> ?>
> --UEXPECT--
> 
> command:
> php run-tests.php -u test.phpt
> cat test.u.out
> 
> Following Notice is displayed:
> Notice: `fwrite()`: 11 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d
> 
> There in no notice message with PHP6 unicode OFF, please would you confirm that the additional notices with Unicode on are intended? I think it will result in a large number of additional Notices if we use fwrite in a for loop.
>  
> Thanks & Regards
> Nikhil
> 
> 
>       ____________________________________________________________________________________
> Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
