|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-06-01 07:07 UTC] xuyifeng at telekbird dot com dot cn
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 05:00:01 2025 UTC |
I am current using PHP3.06 for Win32, I have found that the PHP author made a same mistaken with me, PHP uses standard C runtime library function fwrite (or write ?) to output binary data, this will produce unexpected result, because under Microsoft Windows/NT, standard output is always opened as text mode, this means that if you output char '\n', it will be outputed as '\r\n', 0x0a will be output as 0x0d0a, so if your image contains char 0x0a, when you output image data, it will outputs 0x0d0a, and the image stream is damaged. to avoid this problem, there is two methods: 1) PHP should call _setmode functions when it startups, result = _setmode( _fileno( stdout ), _O_BINARY); this also resolves another problem: PHP program want to send binary data to user client, but binary stream is changed unexpected. 2) use Win32 API WriteFile, this function needs a Win32 file handle, to get Win32 file handle, you should use _fileno and _get_osfhandle, the later function is in io.h. I recommand use first method. I know Microsoft Windows sucks, but it exists there, we need deal with it. sorry for my poor english, because I am in China, it isn't my native language. I wish PHP make better and better. XuYifeng