[Fixed] Content Search - not work with some characters in ..

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

: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: Use Your Profile Or Signature
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: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Nolan
Posts: 66
Joined: 27 Nov 2013 05:23

[Fixed] Content Search - not work with some characters in ..

Post by Nolan »

XY: fresh v16.50.0205
Mode: Normal
Type: Text
Match unicode: Yes

It seems some (not all) Traditional Chinese characters e.g. 虎 牛 狗 in an UTF-8 encoded txt file can't be identified by XY's Content Search. Performing a Content Search with any of those characters will not make the txt file appear in search result.
(If those characters exist In a Big5 encoded txt file, the Content Search works well w/o ticking "Match unicode".)
Last edited by Nolan on 11 Apr 2016 16:31, edited 1 time in total.

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

Re: Content Search - not work with some characters in UTF-8

Post by admin »

Untick "Match unicode".

Nolan
Posts: 66
Joined: 27 Nov 2013 05:23

Re: Content Search - not work with some characters in UTF-8

Post by Nolan »

Content Search doesn't work with 虎 / 牛 / 狗 that exists in UTF-8 encoded txt files. However, at least it works with some other Traditional Chinese characters e.g. 貓 馬 鷹 in UTF-8 txt files if "Match unicode" is ticked.

Unticking "Match Unicode", and then performing a Content Search with any of 虎 牛 狗 貓 馬 鷹, will make any UTF-8 txt files containing the character not show up in search result.

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: Content Search - not work with some characters in UTF-8

Post by oXYgen »

I've created files with identical content "sample text" in different encodings (little-endian). Trying to search in "Normal" mode:
  • without "Match unicode"
    found:		ASCII, UTF-8 (-BOM), UTF-8 (+BOM), UTF-16 (+BOM)
    not found:		UTF-16 (-BOM), UTF-32 (-BOM), UTF-32 (+BOM)
  • with "Match unicode"
    found:		UTF-16 (-BOM), UTF-32 (+BOM)
    not found:		ASCII, UTF-8 (-BOM), UTF-32 (-BOM), UTF-8 (+BOM), UTF-16 (+BOM)
User guide states that a text string "Text" will match with "T0e0x0t0". Why it finds UTF-32 and skips UTF-16 when "Match unicode" is checked? Why it finds UTF-8 and UTF-16 when "Match unicode" is unchecked? Why presence of byte order mark (BOM) affects the results? I'm really confused :veryconfused:

Could you explain how "Match unicode" checkbox works?

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

Re: Content Search - not work with some characters in UTF-8

Post by admin »

Nolan wrote:Content Search doesn't work with 虎 / 牛 / 狗 that exists in UTF-8 encoded txt files. However, at least it works with some other Traditional Chinese characters e.g. 貓 馬 鷹 in UTF-8 txt files if "Match unicode" is ticked.

Unticking "Match Unicode", and then performing a Content Search with any of 虎 牛 狗 貓 馬 鷹, will make any UTF-8 txt files containing the character not show up in search result.
Works fine here. The only explanation would be that you are using BOM-less UTF-8 files AND you unticked "Configuration | Preview | Text preview | UTF-8 auto-detection".

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

Re: Content Search - not work with some characters in UTF-8

Post by admin »

oXYgen wrote:I've created files with identical content "sample text" in different encodings (little-endian). Trying to search in "Normal" mode:
  • without "Match unicode"
    found:		ASCII, UTF-8 (-BOM), UTF-8 (+BOM), UTF-16 (+BOM)
    not found:		UTF-16 (-BOM), UTF-32 (-BOM), UTF-32 (+BOM)
  • with "Match unicode"
    found:		UTF-16 (-BOM), UTF-32 (+BOM)
    not found:		ASCII, UTF-8 (-BOM), UTF-32 (-BOM), UTF-8 (+BOM), UTF-16 (+BOM)
User guide states that a text string "Text" will match with "T0e0x0t0". Why it finds UTF-32 and skips UTF-16 when "Match unicode" is checked? Why it finds UTF-8 and UTF-16 when "Match unicode" is unchecked? Why presence of byte order mark (BOM) affects the results? I'm really confused :veryconfused:

Could you explain how "Match unicode" checkbox works?
What string did you search?

BTW, UTF-32 is not supported in XY.

PS: "Match unicode" should probably be removed from the UI. It's not very useful and confusing without explanation.

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: Content Search - not work with some characters in UTF-8

Post by oXYgen »

admin wrote:What string did you search?
I search "sample text" or just "text". It makes no difference :eh:
admin wrote:BTW, UTF-32 is not supported in XY.
Why it finds UTF-32 (+BOM) that is actually "t000e000x000t000"? Why it finds UTF-16 (-BOM) but skips UTF-16 (+BOM)? The difference is 2 first bytes "FF FE" in UTF-16 (+BOM).
admin wrote:"Match unicode" should probably be removed from the UI.
What if you include several checkboxes for encodings in a separate dialog box and replace "Match unicode" checkbox with "Encodings..." button?

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

Re: Content Search - not work with some characters in UTF-8

Post by admin »

1) Let's forget about "Match unicode". I will probably remove it. It's not necessary for most users.

2) All other searches work well as advertised. (As I said UTF-32 is not supported)

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: Content Search - not work with some characters in UTF-8

Post by oXYgen »

admin wrote:I will probably remove it.
UTF-16 (-BOM) is not found if "Match unicode" has not been checked. Are you about to combine both search results (with and without "Match unicode")?

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

Re: Content Search - not work with some characters in UTF-8

Post by admin »

oXYgen wrote:UTF-16 (-BOM) is not found if "Match unicode" has not been checked.
UTF-16 without BOM is also not supported. I forgot to mention that. (Never met such a file in real life.)

That it works in this case with "Match unicode" checked is just a coincidence. It would not work for Chinese characters.

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: Content Search - not work with some characters in UTF-8

Post by oXYgen »

admin wrote:(As I said UTF-32 is not supported)
admin wrote:UTF-16 without BOM is also not supported. I forgot to mention that.
Please add this information to the User guide :roll:

Nolan
Posts: 66
Joined: 27 Nov 2013 05:23

Re: Content Search - not work with some characters in UTF-8

Post by Nolan »

I use a fresh XY to test the problem. By default, "UTF-8 auto-detection" is on, and I never change it.
UTF-8_auto-detection_ON.png
For the test, I created 2 .txt files: test_Big5.txt and test_UTF-8.txt, and put them in the same folder: TEST. test_Big5.txt is BIg5 encoded, and test_UTF-8.txt is UTF-8 encoded with BOM. Both .txt files have the same text content:
貓 馬 鷹
虎 牛 狗

XY's Preview shows the text content and decoding of each .txt file:

the text content and decoding of test_Big5.txt
Big5_txt_content.png
the text content and decoding of test_UTF-8.txt
UTF-8_with_BOM_txt_content.png
Search result of a Content Search: 貓 In folder: TEST when "Match unicode" is OFF:
find_貓_matchunicode_OFF.png
Search result of a Content Search: 貓 In folder: TEST when "Match unicode" is ON :
find_貓_matchunicode_ON.png
Search result of a Content Search: 虎 In folder: TEST when "Match unicode" is OFF :
find_虎_matchunicode_OFF.png
Search result of a Content Search: 虎 In folder: TEST when "Match unicode" is ON :
find_虎_matchunicode_ON.png
 
To see the attached files, you need to log into the forum.

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

Re: Content Search - not work with some characters in UTF-8

Post by admin »

OK, I see, and I could reproduce it.

The problem here is that Big5 has no BOM, and there is no safe way to detect a Big5 (or any other BOM-less) encoding by scanning the byte patterns. So you would have to tell XY the encoding of the file. This is currently not possible in content search.

Now in your case Big5 appears to be the system default so I would have expected that it works out of the box. I will check this now...

... well, it's complex and hard to debug. I have to switch back and forth between German and Chinese regional settings all the time, and need to compile the app for testing each time since the source code is garbled under Chinese regional settings. I finally thought I had it but for reasons I don't understand it failed. I'm currently out of ideas. Nevertheless I upload the beta version. Maybe it works at your end.

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: Content Search - not work with some characters in UTF-8

Post by oXYgen »

admin wrote:Renamed "Match unicode" to "Match wide strings". More correct, less confusing.
Could you explain what it is used for? Example? I've searched the forum but found nothing related to practical usage of this feature :|

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

Re: Content Search - not work with some characters in UTF-8

Post by admin »

The tooltip explains it.

Post Reply