On Sat, 18 Oct 2014 16:56:09 +
Lucas Burson via Digitalmars-d-learn
wrote:
> Wow, your changes made it much simpler. Thank you for the
> suggestions and expertise ketmar :)
you're welcome.
signature.asc
Description: PGP signature
On Saturday, 18 October 2014 at 00:53:57 UTC, ketmar via
Digitalmars-d-learn wrote:
On Sat, 18 Oct 2014 00:32:09 +
Lucas Burson via Digitalmars-d-learn
wrote:
Wow, your changes made it much simpler. Thank you for the
suggestions and expertise ketmar :)
On Sat, 18 Oct 2014 00:32:09 +
Lucas Burson via Digitalmars-d-learn
wrote:
p.s. it's ok to take '.length' from 'null' array. compiler is smart
enough.
signature.asc
Description: PGP signature
On Sat, 18 Oct 2014 00:32:09 +
Lucas Burson via Digitalmars-d-learn
wrote:
> On Friday, 17 October 2014 at 17:40:09 UTC, ketmar via
> Digitalmars-d-learn wrote:
>
> > i developed a habit of making such buffers one byte bigger than
> > necessary and just setting the last byte to 0 before
>
On Friday, 17 October 2014 at 17:40:09 UTC, ketmar via
Digitalmars-d-learn wrote:
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.
Perfect, great idea. Below is my ut
On Fri, 17 Oct 2014 16:08:04 +
Lucas Burson via Digitalmars-d-learn
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 on
On Friday, 17 October 2014 at 15:30:52 UTC, ketmar via
Digitalmars-d-learn wrote:
On Fri, 17 Oct 2014 15:24:21 +
Lucas Burson via Digitalmars-d-learn
wrote:
So given the below buffer would I use fromStringz (is this in
the stdlib?) to cast it from a null-terminated buffer to a
good string
On Fri, 17 Oct 2014 18:30:43 +0300
ketmar via Digitalmars-d-learn
wrote:
> > Shouldn't the compiler give a warning about casting a
> > buffer to a string without using fromStringz?
nope. such casting is perfectly legal, as D strings can contain
embedded '\0's.
signature.asc
Description: PGP si
On Fri, 17 Oct 2014 15:24:21 +
Lucas Burson via Digitalmars-d-learn
wrote:
> So given the below buffer would I use fromStringz (is this in the
> stdlib?) to cast it from a null-terminated buffer to a good
> string? Shouldn't the compiler give a warning about casting a
> buffer to a string
On Friday, 17 October 2014 at 08:31:04 UTC, spir via
Digitalmars-d-learn wrote:
On 17/10/14 09:29, thedeemon via Digitalmars-d-learn wrote:
On Friday, 17 October 2014 at 06:29:24 UTC, Lucas Burson wrote:
// This is where things breaks
{
ubyte[] buff = new ubyte[16];
buff[0..ATA_S
On 17/10/14 09:29, thedeemon via Digitalmars-d-learn wrote:
On Friday, 17 October 2014 at 06:29:24 UTC, Lucas Burson wrote:
// This is where things breaks
{
ubyte[] buff = new ubyte[16];
buff[0..ATA_STR.length] = cast(ubyte[])(ATA_STR);
// read the string back from the
You fill first few chars with data from
ATA_STR but the rest 10 bytes of the array are still part of
the string
Edit: you fill first 5 chars and have 11 bytes of zeroes in the
tail. My counting skill is too bad. ;)
On Friday, 17 October 2014 at 06:29:24 UTC, Lucas Burson wrote:
// This is where things breaks
{
ubyte[] buff = new ubyte[16];
buff[0..ATA_STR.length] = cast(ubyte[])(ATA_STR);
// read the string back from the buffer, stripping
whitespace
string stringFromBuffer =
13 matches
Mail list logo