View source code
Display the source code in std/conv.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Enum member std.conv.hexString
Converts a hex literal to a string at compile time.
enum hexString(string hexData)
= mixin(hexToString(hexData));
enum hexString(wstring hexData)
= mixin(hexToString(hexData));
enum hexString(dstring hexData)
= mixin(hexToString(hexData));
Takes a string made of hexadecimal digits and returns the matching string by converting each pair of digits to a character. The input string can also include white characters, which can be used to keep the literal string readable in the source code.
The function is intended to replace the hexadecimal literal strings
starting with 'x'
, which could be removed to simplify the core language.
Parameters
Name | Description |
---|---|
hexData | string to be converted. |
Returns
a string
, a wstring
or a dstring
, according to the type of hexData.
Example
// conversion at compile time
auto string1 = hexString!"304A314B";
writeln(string1); // "0J1K"
auto string2 = hexString!"304A314B"w;
writeln(string2); // "0J1K"w
auto string3 = hexString!"304A314B"d;
writeln(string3); // "0J1K"d
Authors
Walter Bright, Andrei Alexandrescu, Shin Fujishiro, Adam D. Ruppe, Kenji Hara
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.