String created from buffer has wrong length and strip() result is incorrect

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 17 10:39:59 PDT 2014


On Fri, 17 Oct 2014 16:08:04 +0000
Lucas Burson via Digitalmars-d-learn
<digitalmars-d-learn at puremagic.com> wrote:

> The buffer is populated from a scsi ioctl so it "should" be only 
> ascii and null-terminated but it's a good idea to harden the code 
> a bit.
> Thank you for your help!
i developed a habit of making such buffers one byte bigger than
necessary and just setting the last byte to 0 before converting. this
way it's guaranteed to be 0-terminated.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141017/eefab415/attachment.sig>


More information about the Digitalmars-d-learn mailing list