Re: Convert a hex string into a ubyte[] or OutBuffer

2016-01-08 Thread zabruk70 via Digitalmars-d-learn
On Thursday, 7 January 2016 at 23:15:41 UTC, Basile B. wrote: Damn, I've been trapped, thread exhumated from 2014 ... Yes, but my post was made yesterday. I don't want create new post and found this. Thank you for your time.

Re: Convert a hex string into a ubyte[] or OutBuffer

2016-01-07 Thread Basile B. via Digitalmars-d-learn
On Thursday, 7 January 2016 at 21:00:06 UTC, zabruk70 wrote: Hello. In modern phobos ver 2.069.1 exists template hexString https://dlang.org/phobos/std_conv.html#.hexString to convert hex string to bytes. It works in compile time only. But what if i need it in run time? Is the answer in this

Re: Convert a hex string into a ubyte[] or OutBuffer

2016-01-07 Thread Basile B. via Digitalmars-d-learn
On Thursday, 7 January 2016 at 21:00:06 UTC, zabruk70 wrote: Hello. In modern phobos ver 2.069.1 exists template hexString https://dlang.org/phobos/std_conv.html#.hexString to convert hex string to bytes. It works in compile time only. But what if i need it in run time? Is the answer in this

Re: Convert a hex string into a ubyte[] or OutBuffer

2016-01-07 Thread zabruk70 via Digitalmars-d-learn
Hello. In modern phobos ver 2.069.1 exists template hexString https://dlang.org/phobos/std_conv.html#.hexString to convert hex string to bytes. It works in compile time only. But what if i need it in run time? Is the answer in this topic still best way? Or now we have some function/template in

Convert a hex string into a ubyte[] or OutBuffer

2014-05-19 Thread Darren via Digitalmars-d-learn
Hi, I'm trying to do something very basic with large numbers: Let's say I have a hex representation of a large number: String hexnum = 16D81B16E091F31BEF; I'd like to convert it into a ubyte[] in order to Base64 encode it (or, indeed ASCII85 or Base32). eg, [16, D8, 1B, 16, E0, 91, F3, 1B,

Re: Convert a hex string into a ubyte[] or OutBuffer

2014-05-19 Thread bearophile via Digitalmars-d-learn
Darren: Let's say I have a hex representation of a large number: String hexnum = 16D81B16E091F31BEF; I'd like to convert it into a ubyte[] A simple way is to use hex strings and then cast it to immutable(ubyte)[]: void main() { immutable hexNum =

Re: Convert a hex string into a ubyte[] or OutBuffer

2014-05-19 Thread anonymous via Digitalmars-d-learn
On Monday, 19 May 2014 at 11:36:43 UTC, Darren wrote: String hexnum = 16D81B16E091F31BEF; string (lowercase) I'd like to convert it into a ubyte[] in order to Base64 encode it (or, indeed ASCII85 or Base32). eg, [16, D8, 1B, 16, E0, 91, F3, 1B, EF] Is there an idiomatic/simple way to do

Re: Convert a hex string into a ubyte[] or OutBuffer

2014-05-19 Thread Darren via Digitalmars-d-learn
On Monday, 19 May 2014 at 12:28:14 UTC, anonymous wrote: On Monday, 19 May 2014 at 11:36:43 UTC, Darren wrote: Is there an idiomatic/simple way to do that? import std.conv: parse; import std.array: array; import std.range: chunks; import std.algorithm: map; ubyte[] bytes = hexnum /* 16D8...