Files and UTF

Mike Surette mjsurette at gmail.com
Thu Aug 6 12:01:29 UTC 2020


On Thursday, 6 August 2020 at 07:24:23 UTC, WebFreak001 wrote:
> On Thursday, 6 August 2020 at 07:19:37 UTC, WebFreak001 wrote:
>> [...]
>
> In line 11 in my example code this makes a better, safer if 
> than `if (s.length)`:
> if (s.length && s[$ - 1] == '\n') s = s[0 .. $ - 1];
>
> Note that I only need to do this because of the readln API, it 
> would be much safer and more correct to instead load the whole 
> file into memory in a byte[].

Thanks for the detailed answer. Now to study it.

Mike


More information about the Digitalmars-d-learn mailing list