string to hex convert
Cym13
cpicard at openmailbox.org
Thu Mar 29 21:23:08 UTC 2018
On Thursday, 29 March 2018 at 20:29:39 UTC, aerto wrote:
> how i can convert Hello world! to hex 48656c6c6f20776f726c6421
> ??
Maybe something like:
void main() {
// Those look like lots of imports but most of those are very
common anyway
import std.digest: toHexString;
import std.stdio: writeln;
string s = "Hello world!";
(cast(ubyte[]) s) // We want raw bytes...
.toHexString // ...convert them to hex...
.writeln; // ...and print.
}
More information about the Digitalmars-d-learn
mailing list