Re: Files and UTF

2020-08-06 Thread Mike Surette via Digitalmars-d-learn
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

Re: Files and UTF

2020-08-06 Thread WebFreak001 via Digitalmars-d-learn
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

Re: Files and UTF

2020-08-06 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 5 August 2020 at 17:39:36 UTC, Mike Surette wrote: In my efforts to learn D I am writing some code to read files in different UTF encodings with the aim of having them end up as UTF-8 internally. As a start I have the following code: import std.stdio; import std.file; void main

Files and UTF

2020-08-05 Thread Mike Surette via Digitalmars-d-learn
In my efforts to learn D I am writing some code to read files in different UTF encodings with the aim of having them end up as UTF-8 internally. As a start I have the following code: import std.stdio; import std.file; void main(string[] args) { if (args.length == 2) { if (args