Implicit conversion of string to array of immutable ubytes

Andy Valencia dont at spam.me
Fri May 23 23:06:25 UTC 2025


On Saturday, 23 March 2024 at 06:55:41 UTC, Jonathan M Davis 
wrote:
> If you want to do that conversion without a cast, then you can 
> just use std.string.representation (which will do the cast 
> internally).

I somehow missed this in Programming in D, and even here on the 
forum.  So just noting that if your code is straddling the worlds 
of ubyte[] and string, "representation" from std.string will give 
you the immutable ubyte[] (or ushort[]/uint[] as appropriate) for 
a string which you want to feed into a ubyte[] based API.

Andy



More information about the Digitalmars-d-learn mailing list