utils: Use _wfopen and _wfreopen on Windows #13866
pull ken2812221 wants to merge 1 commits into bitcoin:master from ken2812221:fopen-windows changing 1 files +5 −0-
ken2812221 commented at 5:00 pm on August 3, 2018: contributorThe fopen function does not support unicode filename on Windows, so use Windows specific function do deal with it.
-
ken2812221 force-pushed on Aug 3, 2018
-
Empact commented at 5:33 pm on August 3, 2018: member
-
ken2812221 commented at 5:40 pm on August 3, 2018: contributor@Empact They are the same if we ignore the errno.
-
DrahtBot commented at 7:37 pm on August 3, 2018: member
-
in src/utilstrencodings.cpp:554 in 5de811917e outdated
547@@ -544,3 +548,13 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out) 548 return true; 549 } 550 551+#ifdef WIN32 552+std::wstring Utf8ToWide(const std::string& utf8_string) 553+{ 554+ size_t size = MultiByteToWideChar(CP_UTF8, 0, &*utf8_string.begin(), utf8_string.size(), nullptr, 0);
donaloconnor commented at 9:09 pm on August 3, 2018: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.
ken2812221 commented at 11:13 pm on August 3, 2018:This avoid the unnecessary copy,&*utf8_string.begin()
point to where the exact string data are.c_str()
anddata()
is a copy of the string data.
donaloconnor commented at 9:04 pm on August 4, 2018: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. -
in src/utilstrencodings.cpp:557 in 5de811917e outdated
552+std::wstring Utf8ToWide(const std::string& utf8_string) 553+{ 554+ size_t size = MultiByteToWideChar(CP_UTF8, 0, &*utf8_string.begin(), utf8_string.size(), nullptr, 0); 555+ std::wstring wide_string(size, 0); 556+ size = MultiByteToWideChar(CP_UTF8, 0, &*utf8_string.begin(), utf8_string.size(), &*wide_string.begin(), wide_string.size()); 557+ assert(size == wide_string.size());
donaloconnor commented at 9:10 pm on August 3, 2018:Is this assert necessary? MultiByteToWideChar won’t change the size of the string.
ken2812221 commented at 11:13 pm on August 3, 2018:They won’t change, so that’s why I use assert instead of a bunch of error handling.
donaloconnor commented at 9:03 pm on August 4, 2018:I didn’t spot the size= part before the asset. Sorry :) -
fanquake added the label Windows on Aug 4, 2018
-
fanquake added the label Utils/log/libs on Aug 4, 2018
-
in src/fs.cpp:4 in 5de811917e outdated
0@@ -1,15 +1,24 @@ 1 #include <fs.h> 2+#include <utilstrencodings.h>
practicalswift commented at 5:58 am on August 4, 2018:nit: Make this include conditional onWIN32
? -
ken2812221 force-pushed on Aug 4, 2018
-
ken2812221 force-pushed on Aug 5, 2018
-
ken2812221 force-pushed on Aug 5, 2018
-
ken2812221 force-pushed on Aug 5, 2018
-
ken2812221 force-pushed on Aug 5, 2018
-
ken2812221 commented at 3:30 pm on August 5, 2018: contributorUpdate: use std codecvt instead of custom converter.
-
ken2812221 renamed this:
utils: Use _wfopen and _wreopen on Windows
utils: Use _wfopen and _wfreopen on Windows
on Aug 16, 2018 -
laanwj added this to the "Blockers" column in a project
-
ken2812221 force-pushed on Aug 21, 2018
-
DrahtBot added the label Needs rebase on Aug 29, 2018
-
ken2812221 force-pushed on Aug 29, 2018
-
DrahtBot removed the label Needs rebase on Aug 29, 2018
-
laanwj removed this from the "Blockers" column in a project
-
utils: Use _wfopen and _wreopen on Windows
The fopen function does not support unicode filename on Windows, so use Windows specific function do deal with it
-
ken2812221 force-pushed on Aug 31, 2018
-
ryanofsky commented at 10:34 pm on September 6, 2018: memberutACK b9babc82dd6a0a4f6f623fcbe5330962eb37eccf
-
ryanofsky approved
-
laanwj commented at 7:02 am on September 11, 2018: memberutACK b9babc82dd6a0a4f6f623fcbe5330962eb37eccf
-
laanwj merged this on Sep 11, 2018
-
laanwj closed this on Sep 11, 2018
-
laanwj referenced this in commit 3783b139e9 on Sep 11, 2018
-
ken2812221 deleted the branch on Sep 11, 2018
-
deadalnix referenced this in commit 7fa094b10e on Nov 10, 2020
-
kittywhiskers referenced this in commit 8faef695ba on May 19, 2021
-
kittywhiskers referenced this in commit f7cf4578e6 on May 19, 2021
-
kittywhiskers referenced this in commit 7546d16953 on May 20, 2021
-
kittywhiskers referenced this in commit 7a3d581c4b on May 20, 2021
-
kittywhiskers referenced this in commit 59d2834951 on May 20, 2021
-
kittywhiskers referenced this in commit abffb58b5e on May 20, 2021
-
PastaPastaPasta referenced this in commit b76e7fec1f on May 21, 2021
-
random-zebra referenced this in commit 61a098a775 on Aug 5, 2021
-
DrahtBot locked this on Sep 8, 2021