How to convert hex string to string or ubytes? Thanks.
FrankLike
1150015857 at qq.com
Mon Feb 5 08:41:43 UTC 2018
On Monday, 5 February 2018 at 06:12:22 UTC, H. S. Teoh wrote:
> On Mon, Feb 05, 2018 at 05:48:00AM +0000, FrankLike via
> auto input = "48656c6c6f20776f726c6421";
> auto str = input.chunks(2)
> .map!(digits => cast(char) digits.to!ubyte(16))
> .array;
But,if the input come from here:
import std.digest.md;
auto hash =md5Of("Some Words");
auto input = cast(string)hexString(hash);
auto str = input.chunks(2)
.map!(digits => cast(char) digits.to!ubyte(16))
.array;
Then get an error:
core.exception.UnicodeException at src\rt\util\utf.d(292):invalid
UTF-8 sequence
--------------
0x0041B8E6
0x00419530
0x0040796F
Thanks.
More information about the Digitalmars-d-learn
mailing list