On Thu, 09 Oct 2014 20:08:11 +
bearophile via Digitalmars-d-learn
wrote:
> The problem is that cast. No one wants a string, most people want
> a ubyte[].
This doesn't make the cut. it's handy, people wants it, it will break
almost nothing... no way.
signature.asc
Description: PGP signature
ketmar:
additionally to all bearophile said, there is another
interesting thing in D: special string literals for hex data.
immutable ubyte[] n = cast(typeof(n))x"deadf00d";
or even:
immutable ubyte[] n = cast(typeof(n))x"de ad f 0 0 d";
spaces doesn't matter, only digits do.
The prob
On Thu, 09 Oct 2014 15:26:52 +
Anibal via Digitalmars-d-learn
wrote:
additionally to all bearophile said, there is another interesting thing
in D: special string literals for hex data.
immutable ubyte[] n = cast(typeof(n))x"deadf00d";
or even:
immutable ubyte[] n = cast(typeof(n))x"de
On Thursday, 9 October 2014 at 15:41:48 UTC, bearophile wrote:
You want ubytes (unsigned bytes) because 0x04 is 164 that is
bigger than byte.max.
I'd like bytes to be named sbyte and ubyte in D, but Walter has
refused this.
Bye,
bearophile
Got it to work, thanks a lot!
You want ubytes (unsigned bytes) because 0x04 is 164 that is
bigger than byte.max.
I'd like bytes to be named sbyte and ubyte in D, but Walter has
refused this.
Bye,
bearophile
Anibal:
byte[] arr = [ 0x00, 0xA4, 0x04];
This throws a int[] to byte[] cast error
You want ubytes (unsigned bytes) because 0x04 is 164 that is
bigger than byte.max.
So use:
ubyte[] arr = [ 0x00, 0xA4, 0x04];
I also tried
byte[] arr = [cast(byte) 0x00, cast(byte)0xA4, cast(byte) 0x04];
Hi everyone,
I'm just starting with D and i need a way to declare a byte array
something like:
byte[] arr = [ 0x00, 0xA4, 0x04];
This throws a int[] to byte[] cast error
Tried also these ones
byte[] arr = "\x00\xA4\x04";
byte[] arr = [ '\x00', '\xA4', '\x04'];
byte[] arr = [ u'\x00', u'\xA4',