Byte Array Literal
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Oct 9 13:08:11 PDT 2014
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 problem is that cast. No one wants a string, most people want
a ubyte[].
See:
https://issues.dlang.org/show_bug.cgi?id=3850
https://issues.dlang.org/show_bug.cgi?id=5909
https://issues.dlang.org/show_bug.cgi?id=10454
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list