Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10454 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75537 invoked by uid 1010); 14 Jun 2004 19:18:13 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 75513 invoked by uid 1007); 14 Jun 2004 19:18:12 -0000 Message-ID: <20040614191812.75512.qmail@pb1.pair.com> To: internals@lists.php.net References: <40CDD0EC.5070905@php-tools.net> <20040614171119.24785.qmail@pb1.pair.com> <40CDE75C.3010502@php-tools.net> <20040614182658.38550.qmail@pb1.pair.com> <40CDF306.9010107@php-tools.net> Date: Mon, 14 Jun 2004 12:18:11 -0700 Lines: 23 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Posted-By: 169.229.135.175 Subject: Re: [PHP-DEV] Re: Need help with streams From: pollita@php.net ("Sara Golemon") > 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), Z_STRLEN_PP(data)); php_stream_write(stream, blanks, 30 - Z_STRLEN_PP(data)); } 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. -Sara