Re: dmd Regression(?): bigEndianToNative buffer slice allows only literals

2015-05-13 Thread Lucas Burson via Digitalmars-d-learn
I reported this as a regression https://issues.dlang.org/show_bug.cgi?id=14582

dmd Regression(?): bigEndianToNative buffer slice allows only literals

2015-05-13 Thread Lucas Burson via Digitalmars-d-learn
The std.batmanip bigEndianToNative has a regression where the slice range doesn't work with variables (only literals). Is the syntax incorrect or is this a regression in dmd? Using this main.d: import std.bitmanip; int main(string args[]) { auto datain = new ubyte[16]; // this syntax wor

Re: bitmanip bigEndianToNative using a buffer slice?

2014-10-21 Thread Lucas Burson via Digitalmars-d-learn
On Wednesday, 22 October 2014 at 01:08:52 UTC, ketmar via Digitalmars-d-learn wrote: the short answer: uint fromBuf = bigEndianToNative!uint(cast(ubyte[4])buffer[offset..offset+4]); ketmar, we meet again! Your explanation is great and that solved my problem. Thank you. Maybe I'll try out t

bitmanip bigEndianToNative using a buffer slice?

2014-10-21 Thread Lucas Burson via Digitalmars-d-learn
I'm trying to create a primitive type given a specific buffer slice. I can place the uint into a sliced buffer but I'm getting compiler errors when using a slice to create the uint. Still new to Dlang and unfamiliar with the template system. How do I get this working? import std.bitmanip; int

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

2014-10-18 Thread Lucas Burson via Digitalmars-d-learn
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 :)

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

2014-10-17 Thread Lucas Burson via Digitalmars-d-learn
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

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

2014-10-17 Thread Lucas Burson via Digitalmars-d-learn
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

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

2014-10-17 Thread Lucas Burson via Digitalmars-d-learn
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

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

2014-10-16 Thread Lucas Burson via Digitalmars-d-learn
When creating a string from a ubyte[], I have an invalid length and string.strip() doesn't strip off all whitespace. I'm new to the language. Is this a compiler issue? import std.string : strip; import std.stdio : writefln; int main() { const string ATA_STR = " ATA "; // this works fi