filetype() - ASCII - UTF-8

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
zakhar
Posts: 179
Joined: 08 Sep 2010 21:13

filetype() - ASCII - UTF-8

Post 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.

admin
Site Admin
Posts: 66622
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: filetype() - ASCII - UTF-8

Post by admin »

UTF-8 is only checked for Text Files which are recognized via the extension (Configuration | Preview | Previewed Formats | Categories).

Wrong! See below...

highend
Posts: 14992
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: filetype() - ASCII - UTF-8

Post 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!
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 66622
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: filetype() - ASCII - UTF-8

Post 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...

zakhar
Posts: 179
Joined: 08 Sep 2010 21:13

Re: filetype() - ASCII - UTF-8 [SOLVED]

Post 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!

jupe
Posts: 3462
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: filetype() - ASCII - UTF-8

Post 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;

admin
Site Admin
Posts: 66622
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: filetype() - ASCII - UTF-8

Post by admin »

Actually it was caused by the UTF-8 related changes in v23.00.0102 - 2022-04-22 15:24. Fix comes. :tup:

Post Reply