Re: from bytes to string

2021-11-27 Thread Coder via Digitalmars-d-learn
On Saturday, 27 November 2021 at 15:29:45 UTC, Adam D Ruppe wrote: On Saturday, 27 November 2021 at 15:24:43 UTC, Coder wrote: Question, why a function can not be nothrow if I catch in the body? Ever play Pokemon? You can't just catch the cute Bulbasaur and call it done (even though the grass

Re: from bytes to string

2021-11-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 27 November 2021 at 15:24:43 UTC, Coder wrote: Question, why a function can not be nothrow if I catch in the body? Ever play Pokemon? You can't just catch the cute Bulbasaur and call it done (even though the grass type is like playing on easy mode). You gotta catch 'em all! vo

Re: from bytes to string

2021-11-27 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Nov 27, 2021 at 03:24:43PM +, Coder via Digitalmars-d-learn wrote: [...] > Question, why a function can not be nothrow if I catch in the body? > > void foo() nothrow { > import std.utf : validate, UTFException; > try { > validate("a"); > } > catch(UTFException){

Re: from bytes to string

2021-11-27 Thread Coder via Digitalmars-d-learn
On Saturday, 27 November 2021 at 13:56:46 UTC, Adam D Ruppe wrote: 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

Re: from bytes to string

2021-11-27 Thread Adam D Ruppe via Digitalmars-d-learn
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.

from bytes to string

2021-11-27 Thread Coder via Digitalmars-d-learn
I'm lost, std.utf, std.conv, std.encoding, std.uni 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? Thank you!