from bytes to string

Adam D Ruppe destructionator at gmail.com
Sat Nov 27 13:56:46 UTC 2021


On Saturday, 27 November 2021 at 13:54:11 UTC, Coder wrote:
> My application is receiving data over a socket as 
> immutable(ubyte)[].
> How to validate them and transform them to utf8 string? What is 
> the best way?

If they're already supposed to be utf8, just cast it to char[] 
then you can call std.utf.validate on it if you want and idup it 
into a string to keep.

If it is some other encoding... then it depends on what encoding.


More information about the Digitalmars-d-learn mailing list