Re: Prevent opening binary/other garbage files

2018-10-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 1 October 2018 at 15:21:24 UTC, helxi wrote: I tried out https://dlang.org/library/std/utf/validate.html before manually checking for encoding myself so I ended up with the code below. I was fairly surprised that "*.o" (object) files are UTF encoded! Is it normal? Yes. Any random

Re: Prevent opening binary/other garbage files

2018-10-01 Thread helxi via Digitalmars-d-learn
On Sunday, 30 September 2018 at 03:19:11 UTC, Adam D. Ruppe wrote: On Saturday, 29 September 2018 at 23:46:26 UTC, helxi wrote: Thanks. Would you say https://dlang.org/library/std/encoding/get_bom.html is useful in this context? Eh, not really, most text files will not have one. Hi, I

Re: Prevent opening binary/other garbage files

2018-09-30 Thread bauss via Digitalmars-d-learn
On Saturday, 29 September 2018 at 15:52:30 UTC, helxi wrote: I'm writing a utility that checks for specific keyword(s) found in the files in a given directory recursively. What's the best strategy to avoid opening a bin file or some sort of garbage dump? Check encoding of the given file? If

Re: Prevent opening binary/other garbage files

2018-09-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 29 September 2018 at 23:46:26 UTC, helxi wrote: Thanks. Would you say https://dlang.org/library/std/encoding/get_bom.html is useful in this context? Eh, not really, most text files will not have one.

Re: Prevent opening binary/other garbage files

2018-09-29 Thread helxi via Digitalmars-d-learn
On Saturday, 29 September 2018 at 16:01:18 UTC, Adam D. Ruppe wrote: On Saturday, 29 September 2018 at 15:52:30 UTC, helxi wrote: I'm writing a utility that checks for specific keyword(s) found in the files in a given directory recursively. What's the best strategy to avoid opening a bin file

Re: Prevent opening binary/other garbage files

2018-09-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 29 September 2018 at 15:52:30 UTC, helxi wrote: I'm writing a utility that checks for specific keyword(s) found in the files in a given directory recursively. What's the best strategy to avoid opening a bin file or some sort of garbage dump? Check encoding of the given file?