My language of windows is Chinese, I can use Korean `리마스터` to search file in Everything.exe
But when I use the same keyword to search by the following code, I'll get lots of results which don't match my keyword, seems the SDK has bug, I think it always use default encoder of windows, and `리마스터` can't encode correctly, so it encoded as `????`, those lots of result are macthed to keyword `????`
```C#
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
class Program
{
static void Main()
{
var files = FindFiles("리마스터"); // Chinese/English word work fine
var files2 = FindFiles("????");
Console.WriteLine(files.SetEquals(files2));
Console.ReadKey();
}
[DllImport("Everything64.dll", CharSet = CharSet.Unicode)]
public static extern void Everything_GetResultFullPathNameW(int nIndex, StringBuilder lpString, int nMaxCount);
[DllImport("Everything64.dll", CharSet = CharSet.Unicode)]
public static extern void Everything_SetSearch(string lpSearchString);
[DllImport("Everything64.dll")]
public static extern void Everything_Query(bool bWait);
[DllImport("Everything64.dll")]
public static extern int Everything_GetNumResults();
public static HashSet<string> FindFiles(string fileName)
{
var list = new HashSet<string>();
Everything_SetSearch(fileName);
Everything_Query(true);
int count = Everything_GetNumResults();
for (int i = 0; i < count; i++)
{
StringBuilder sb = new StringBuilder(1000);
Everything_GetResultFullPathNameW(i, sb, sb.Capacity);
list.Add(sb.ToString());
}
return list;
}
}
```
SDK encoder bug
Re: SDK encoder bug
The C# example works when searching for 리마스터
If you are manually typing 리마스터 in your code, please make sure the c# file has unicode support.
You can change this in Visual Studio under File -> Advanced Save Options. (save the file as UTF-8 or other Unicode supported encoding)
If you are manually typing 리마스터 in your code, please make sure the c# file has unicode support.
You can change this in Visual Studio under File -> Advanced Save Options. (save the file as UTF-8 or other Unicode supported encoding)
Re: SDK encoder bug
No, I think it work only when the windows language is Korean also.
There's one more test:
This time I use English keyword `mytest123.txt`, and it work fine in Everything.exe, but when I search this keyword by SDK, I get `????` rather than original Koeran string also: My version is Everything-1.4.1.1024.x64, and SDK dll modified time is 2023/06/13
There's one more test:
This time I use English keyword `mytest123.txt`, and it work fine in Everything.exe, but when I search this keyword by SDK, I get `????` rather than original Koeran string also: My version is Everything-1.4.1.1024.x64, and SDK dll modified time is 2023/06/13
Last edited by ssyfzy on Fri Jul 12, 2024 11:40 pm, edited 2 times in total.
Re: SDK encoder bug
Please change the declaration of Everything_SetSearch to:
[DllImport("Everything64.dll", CharSet = CharSet.Unicode)]
public static extern void Everything_SetSearchW(string lpSearchString);
Please change the declaration of Everything_QueryW to:
[DllImport("Everything64.dll")]
public static extern bool Everything_QueryW(bool bWait);
[DllImport("Everything64.dll", CharSet = CharSet.Unicode)]
public static extern void Everything_SetSearchW(string lpSearchString);
Please change the declaration of Everything_QueryW to:
[DllImport("Everything64.dll")]
public static extern bool Everything_QueryW(bool bWait);
Re: SDK encoder bug
Useless.
I already tested that before I posted this topic.
Maybe you do something in SDK like this: Default encoder can't encode Korean correctly, maybe you should always use Unicode/UTF8 in SDK dll
I already tested that before I posted this topic.
Maybe you do something in SDK like this: Default encoder can't encode Korean correctly, maybe you should always use Unicode/UTF8 in SDK dll
Last edited by ssyfzy on Fri Jul 12, 2024 11:56 pm, edited 1 time in total.
Re: SDK encoder bug
The SDK supports Unicode.
This is an encoding issue with your C# file.
This is an encoding issue with your C# file.
Re: SDK encoder bug
[DllImport("Everything64.dll", CharSet = CharSet.Unicode)]
public static extern void Everything_Query(bool bWait);
Everything_Query should also use unicode version.
This function doesn't take any string parameter, that's why I thought it's unnecessary to set CharSet. I haven't seen any other API without string parameter need CharSet in the past.
Fixed, thanks!
public static extern void Everything_Query(bool bWait);
Everything_Query should also use unicode version.
This function doesn't take any string parameter, that's why I thought it's unnecessary to set CharSet. I haven't seen any other API without string parameter need CharSet in the past.
Fixed, thanks!