Hi,
That's because you're telling it to write one character from the position POINTED TO by the integer value. (i.e. Treat the integer like a pointer) You're lucky you're getting data at all and not a segfault.
Try:
php_stream_putc(stream, (char)(Z_LVAL_P(*data) & 0xFF));
You are a livesaver! Thanks very much. I got one more problem though:
What's the best way to create a string with a fixed length, that's padded with zero-bytes?
I'm currently using:
php_stream_write(stream, Z_STRVAL_P(*data), 30);
As the string is terminated with a zero-byte, it already works, but it would be better to fill the unused space with zero-bytes.
Do I have to create a second buffer and copy byte-by-byte and then fill the remaining bytes with zeros, or is there an easier way? The only other solution I could think of is to check for the exact length of the string, write the string and then use php_stream_putc() in a loop to write the remaining zero bytes...
Stephan
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php