-
Notifications
You must be signed in to change notification settings - Fork 242
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
Parameter loading fails when the filesystem encoding is not UTF-8 #44
Comments
We have a lot of Russian and Chinese users, so this is going to crop up a lot. Note that it's a regression in recent versions of zcashd (post-1.1.2 I think), because this code was not previously used and the C++ code does handle non-ASCII filenames correctly. |
yes it is post-1.1.2, 2.0.0 didn't build on Windows (because #reasons), so it didn't pop up until now |
|
The Rust code can't be unchanged, because it calls |
On Windows, the slices are [u16] representing UTF-16. On all other platforms, the slices are [u8] in the native filesystem encoding. Closes zcash#44.
Most Windows systems when using ANSI APIs, and some Unix systems, do not use UTF-8 encoding for filesystem paths. It's also common for usernames to have non-ASCII characters. In that case parameter loading will fail here:
librustzcash/librustzcash/src/rustzcash.rs
Lines 144 to 157 in 041671f
The comment is correct; we should not be using
CStr
, sinceCStr::to_str
assumes UTF-8 (see doc just above here).Strictly speaking the Right Way to do it on Windows is to use "wide" (UTF-16) filesystem APIs. I don't know how well supported that is in Rust, and for now I'd recommend sticking to ANSI APIs and just passing the bytes through as-is.
The text was updated successfully, but these errors were encountered: