Hi,
iirc there may be a printf means to specify NULL as the padding character,
or to repeat an aribtrary character for a certain number of characters, but
it's escaping me at the moment. For the size of your padding this method
should introduce to horrible of a penalty.
Works like a charm, thanks.
> Both solutions will pad the string with ' ', but I need to pad it with
'\0'.
>
Ah, misunderstood you, try this one:
if (Z_STRLEN_PP(data) > 30) {
php_stream_write(stream, Z_STRVAL_PP(data), 30);
} else {
char blanks[30];
memset(blanks, 0, 30);
php_stream_write(stream, Z_STRVAL_PP(data),
Hi,
/* Not binary safe, but depending on your data that may be okay */
if (Z_STRLEN_PP(data) > 30) {
php_stream_write(stream, Z_STRVAL_PP(data), 30);
} else {
php_stream_printf(stream TSRMLS_CC, "%-30s", Z_STRVAL_PP(data));
}
Both solutions will pad the string with ' ', but I need to pad it wit
> 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.
>
Actually, that'll also open the door to a potential segfault since you may
overrun the
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! Th