utils: Use _wfopen and _wfreopen on Windows#13866
utils: Use _wfopen and _wfreopen on Windows#13866laanwj merged 1 commit intobitcoin:masterfrom ken2812221:fopen-windows
Conversation
|
@Empact They are the same if we ignore the errno. |
| No more conflicts as of last run. |
src/utilstrencodings.cpp
Outdated
There was a problem hiding this comment.
I find the &* unnecessarily complicated. Can you use utf8_string.data() or even the more usual c_str() instead that gives a direct pointer back.
There was a problem hiding this comment.
This avoid the unnecessary copy, &*utf8_string.begin() point to where the exact string data are. c_str() and data() is a copy of the string data.
There was a problem hiding this comment.
Not sure what implementation you are referring to but c_str and data have always returned the pointer to the internal data. Not a copy. Anyway it was just a nitpick. Thanks.
src/utilstrencodings.cpp
Outdated
There was a problem hiding this comment.
Is this assert necessary? MultiByteToWideChar won't change the size of the string.
There was a problem hiding this comment.
They won't change, so that's why I use assert instead of a bunch of error handling.
There was a problem hiding this comment.
I didn't spot the size= part before the asset. Sorry :)
src/fs.cpp
Outdated
There was a problem hiding this comment.
nit: Make this include conditional on WIN32?
|
Update: use std codecvt instead of custom converter. |
The fopen function does not support unicode filename on Windows, so use Windows specific function do deal with it
|
utACK b9babc8 |
b9babc8 utils: Use _wfopen and _wreopen on Windows (Chun Kuan Lee) Pull request description: The fopen function does not support unicode filename on Windows, so use Windows specific function do deal with it. Tree-SHA512: 4dcf14dcf9ec6307b9fdf95404e5b6b6b3df640949fd4b0c4ac7fecf8ea03a64fa25285fc319c4ff8a28e586eee106f1861116c181694955497402b2bf575f22
Summary: The fopen function does not support unicode filename on Windows, so use Windows specific function do deal with it This is a backport of Core [[bitcoin/bitcoin#13866 | PR13866]] Test Plan: `ninja && ninja check` Use the build bot to run tests on windows. Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D8343
Merge bitcoin#19660, bitcoin#19373, bitcoin#19841, bitcoin#13862, bitcoin#13866, bitcoin#17280, bitcoin#17682 and partial bitcoin#19326, bitcoin#14978: Auxiliary Backports
63e0be6 [Remove] By-pass logprint-scanner restriction. (furszy) 280ced3 utils: Fix broken Windows filelock (Chun Kuan Lee) be89860 utils: Convert Windows args to utf-8 string (Chun Kuan Lee) e8cfa6e Call unicode API on Windows (Chun Kuan Lee) 1a02a8a tests: Add test case for std::ios_base::ate (Chun Kuan Lee) 2e57cd4 Move boost/std fstream to fsbridge (furszy) 9d8bcd4 utils: Add fsbridge fstream function wrapper (Chun Kuan Lee) d59d48d utils: Convert fs error messages from multibyte to utf-8 (ken2812221) 9ef58cc Logging: use "fmterr" variable name for errors instead of general "e" that can be used by any other function. (furszy) dd94241 utils: Use _wfopen and _wreopen on Windows (Chun Kuan Lee) 3993641 add unicode compatible file_lock for Windows (Chun Kuan Lee) 48349f8 Provide relevant error message if datadir is not writable. (murrayn) Pull request description: As the software is currently using the ANSI encoding on Windows, the user's language settings could affect the proper functioning of the node/wallet, to the point of not be able to open some non-ASCII name files and directories. This solves the Windows encoding issues, completing the entire bitcoin#13869 work path (and some other required backports). Enabling for example users that use non-english characters in directories and file names to be accepted. Backported PRs: * bitcoin#12422. * bitcoin#12630. * bitcoin#13862. * bitcoin#13866. * bitcoin#13877. * bitcoin#13878. * bitcoin#13883. * bitcoin#13884. * bitcoin#13886. * bitcoin#13888. * bitcoin#14192. * bitcoin#13734. * bitcoin#14426. This is built on top of other two PRs that i have open #2423 and #2369. Solves old issues #940 and #2163. TODO: * Backport `assert_start_raises_init_error` and `ErrorMatch` in TestNode` (bitcoin#12718) ACKs for top commit: Fuzzbawls: ACK 63e0be6 random-zebra: ACK 63e0be6 and merging... Tree-SHA512: cb1f7c23abb5b7b3af50bba18652cc2cad93fd7c2fca9c16ffd3fee34c4c152a3b666dfa87fe6b44c430064dcdee4367144dcb4a41203c91b0173b805bdb3d7d
The fopen function does not support unicode filename on Windows, so use Windows specific function do deal with it.