View source code
Display the source code in std/conv.d from which this page was generated on
github.
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.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Variable std.conv.hexString
Converts a hex literal to
a string at compile time.
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.
Declaration
void
hexString(string hexData) = hexStrImpl(hexData);
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"; assert(string1 == "0J1K"); auto string2 = hexString!"304A314B"w; assert(string2 == "0J1K"w); auto string3 = hexString!"304A314B"d; assert(string3 == "0J1K"d);
Authors
Walter Bright, Andrei Alexandrescu, Shin Fujishiro, Adam D. Ruppe, Kenji Hara