Re: Unicode validation for Posix
On Sunday, 3 September 2023 at 10:06:58 UTC, Vino wrote: Hi All, As per the documentation from std.process it states that an exception is thrown if the variable contains invalid UTF-16 characters and it can also be validated using "validate" function from std.utf, so the question is do we have a similar one for Posix as this seem to be applicable only to Windows. ``` Exception if the environment variable does not exist, or std.utf.UTFException if the variable contains invalid UTF-16 characters (Windows only). ``` From, Vino On POSIX, no validation is necessary, because the names of environment variables are allowed to contain any character except for `\0` (including invalid Unicode).
Re: isBinary
On Sunday, 3 September 2023 at 10:15:31 UTC, FeepingCreature wrote: On Sunday, 3 September 2023 at 10:11:22 UTC, Vino wrote: Hi All, Any update as to when the function described in the below ticked would be action-ed, I am more interested in isBinary (check a file whether is is binary file or not) http://d.puremagic.com/issues/show_bug.cgi?id=9455 From, Vino Those are totally different ideas. When writing a file, some operating systems support line ending conversion. To do that, you explicitly specify that you are writing to a text file. Then a "binary file" is just any file that is not a text file. However, this is merely a conversion process on writing. You cannot discover whether a file is a binary file in reverse. At most you can check whether *you yourself* opened the file as a binary file. I tried to write the below code but it always return's as binary for any file type, please point me what is wrong in the below program ``` void main () { import std.stdio: writeln, File; string fn = "C:\\temp\\test.txt"; //string fn = "C:\\WINDOWS\\system32\\whoami.exe"; File f; f.open(fn, "rb"); if(f.isOpen) { writeln("BinaryFile"); } else { writeln("NotBinaryFile"); } f.close(); } ``` From, Vino
Re: isBinary
On Sunday, 3 September 2023 at 10:11:22 UTC, Vino wrote: Hi All, Any update as to when the function described in the below ticked would be action-ed, I am more interested in isBinary (check a file whether is is binary file or not) http://d.puremagic.com/issues/show_bug.cgi?id=9455 From, Vino Those are totally different ideas. When writing a file, some operating systems support line ending conversion. To do that, you explicitly specify that you are writing to a text file. Then a "binary file" is just any file that is not a text file. However, this is merely a conversion process on writing. You cannot discover whether a file is a binary file in reverse. At most you can check whether *you yourself* opened the file as a binary file.
Unicode validation for Posix
Hi All, As per the documentation from std.process it states that an exception is thrown if the variable contains invalid UTF-16 characters and it can also be validated using "validate" function from std.utf, so the question is do we have a similar one for Posix as this seem to be applicable only to Windows. ``` Exception if the environment variable does not exist, or std.utf.UTFException if the variable contains invalid UTF-16 characters (Windows only). ``` From, Vino