Page 1 of 1
filetype() - ASCII - UTF-8
Posted: 26 Apr 2022 16:00
by zakhar
Hello, dear XYplorer Community!
If the file extension is not "txt",
the filetype() seems not to distinguish correctly between encodings "ASCII" and "UTF-8".
Please check it.
Re: filetype() - ASCII - UTF-8
Posted: 27 Apr 2022 12:50
by admin
UTF-8 is only checked for Text Files which are recognized via the extension (Configuration | Preview | Previewed Formats | Categories).
Wrong! See below...
Re: filetype() - ASCII - UTF-8
Posted: 27 Apr 2022 13:06
by highend
Then the recognition doesn't seem to be working correctly
Code: Select all
$file1 = "%TEMP%\~test.log";
$file2 = "%TEMP%\~test.txt";
writefile($file1, "¥", , "utf8");
writefile($file2, "¥", , "utf8");
text "1: " . filetype($file1) . <crlf> . "2: " . filetype($file2);
The .log file isn't recognized correctly, while the .txt file is.
Both extensions are ticked in the Text Files category!
Re: filetype() - ASCII - UTF-8
Posted: 27 Apr 2022 13:12
by admin
Whoops, my fault. It's not "Text Files", it's "UTF-8 Files", a category that's not exposed to the user.
Anyway, I decided to make SC filetype work as advertised and go ONLY by content, not by extension. Next beta...
Re: filetype() - ASCII - UTF-8 [SOLVED]
Posted: 27 Apr 2022 15:50
by zakhar
admin wrote: ↑27 Apr 2022 13:12
Next beta...
Thank you very much!
In v. 23.00.0103 it works as expected.
Used before and after writefile() - for diagnostic and verification, the filetype() is a very useful tool!
Re: filetype() - ASCII - UTF-8
Posted: 29 Apr 2022 04:27
by jupe
I assume because of whatever changes you made regarding this topic, there has been a side effect:
Code: Select all
$file1 = "%TEMP%\~test.log";
writefile($file1, "™", , "utf8");
text runret("cmd /c chcp 65001 & type ""$file1""",, 65001);
delete 0, 1, $file1;
Re: filetype() - ASCII - UTF-8
Posted: 29 Apr 2022 09:40
by admin
Actually it was caused by the UTF-8 related changes in v23.00.0102 - 2022-04-22 15:24. Fix comes.
