Regarding hex strings

bearophile bearophileHUGS at lycos.com
Thu Oct 18 03:05:05 PDT 2012


The docs say:
http://dlang.org/lex.html

>Hex strings allow string literals to be created using hex data. 
>The hex data need not form valid UTF characters.<

But this code:


void main() {
     immutable ubyte[4] data = x"F9 04 C1 E2";
}



Gives me:

temp.d(2): Error: Outside Unicode code space

Are the docs correct?

--------------------------

foobar:

> Seems to me this is in the same ballpark as the built-in 
> complex numbers. Sure it's nice to be able to write "4+5i" 
> instead of "complex(4,5)" but how frequently do you actually 
> ever need the _literals_ even in complex computational heavy 
> code?

Compared to "oct!5151151511", one problem with code like this is 
that binary blobs are sometimes large, so supporting a x"" syntax 
is better:

immutable ubyte[4] data = hex!"F9 04 C1 E2";

Bye,
bearophile


More information about the Digitalmars-d mailing list