Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct way to parse foreign character file names #15

Open
t123yh opened this issue Jan 17, 2017 · 2 comments
Open

Correct way to parse foreign character file names #15

t123yh opened this issue Jan 17, 2017 · 2 comments

Comments

@t123yh
Copy link

t123yh commented Jan 17, 2017

I'm using Chinese Windows and the default name for a new directory is "新建文件夹".
However, after creating the directory the characters turned out to be "鏂板缓鏂囦欢澶?" which is a complete mess. The file name in Linux is correct.

I tried to change line 727 of DokanOperations.cs from

fi.FileName = entry.getFilename();

to

fi.FileName = Encoding.UTF8.GetString(Encoding.Default.GetBytes(Encoding.UTF8.GetString(entry.getFilename().getBytes()))); // Encoding.Default in Chinese Windows is GB2312

and got "新建文件�?" which is nearly correct but the last character is broken.

In the above example, entry.getFilename().getBytes() for "新建文件夹" is as follows:

entry.getFilename().getBytes()
{byte[22]}
    [0]: 233
    [1]: 143
    [2]: 130
    [3]: 230
    [4]: 157
    [5]: 191
    [6]: 231
    [7]: 188
    [8]: 147
    [9]: 233
    [10]: 143
    [11]: 130
    [12]: 229
    [13]: 155
    [14]: 166
    [15]: 230
    [16]: 172
    [17]: 162
    [18]: 230
    [19]: 190
    [20]: 182
    [21]: 63

I created a directory named "新"(a single character), and found entry.getFilename().getBytes() is only a byte long. Obviously it is truncated.

{byte[1]}
    [0]: 46

So I doubt there are some problems with SharpSSH.

@Liryna
Copy link
Member

Liryna commented Jan 19, 2017

Hi @t123yh ,

Can you test the C# mirror https://github.com/dokan-dev/dokan-dotnet/tree/master/sample/DokanNetMirror to see if you have the same issue ?

Maybe it is something in c# implementation

@hyy829119
Copy link

hyy829119 commented Apr 19, 2017

这个问题我这边已经解决,解决方案如下:在Tamir.SharpSSh.dll动态连接库中,
channelSftp.cs的1415行,改为如下:
v.addElement(new LsEntry(System.Text.Encoding.UTF8.GetString(filename), longname, attrs));
就可以解决!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants