string to ubyte[]

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Aug 14 17:31:55 UTC 2019


On Wed, Aug 14, 2019 at 03:11:44PM +0000, berni via Digitalmars-d-learn wrote:
[...]
> but unfortunately this does not work:
> 
> >    ubyte[] convert_string_pair(string first, string second)
> >    {
> >        return 0x00 ~ first ~ 0x00 ~ second ~ 0x00;
> >    }
> 
> The reason is, that this expression creates a string and not a
> ubyte[]...

Try:

   ubyte[] convert_string_pair(string first, string second)
   {
       return cast(ubyte[])(0x00 ~ first ~ 0x00 ~ second ~ 0x00);
   }


T

-- 
What did the alien say to Schubert? "Take me to your lieder."


More information about the Digitalmars-d-learn mailing list