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
  1. ken2812221 commented at 5:00 pm on August 3, 2018: contributor
    The fopen function does not support unicode filename on Windows, so use Windows specific function do deal with it.
  2. ken2812221 force-pushed on Aug 3, 2018
  3. ken2812221 commented at 5:40 pm on August 3, 2018: contributor
    @Empact They are the same if we ignore the errno.
  4. DrahtBot commented at 7:37 pm on August 3, 2018: member
  5. 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() and data() 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.
  6. 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 :)
  7. fanquake added the label Windows on Aug 4, 2018
  8. fanquake added the label Utils/log/libs on Aug 4, 2018
  9. 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 on WIN32?
  10. ken2812221 force-pushed on Aug 4, 2018
  11. ken2812221 force-pushed on Aug 5, 2018
  12. ken2812221 force-pushed on Aug 5, 2018
  13. ken2812221 force-pushed on Aug 5, 2018
  14. ken2812221 force-pushed on Aug 5, 2018
  15. ken2812221 commented at 3:30 pm on August 5, 2018: contributor
    Update: use std codecvt instead of custom converter.
  16. ken2812221 renamed this:
    utils: Use _wfopen and _wreopen on Windows
    utils: Use _wfopen and _wfreopen on Windows
    on Aug 16, 2018
  17. laanwj added this to the "Blockers" column in a project

  18. ken2812221 force-pushed on Aug 21, 2018
  19. DrahtBot added the label Needs rebase on Aug 29, 2018
  20. ken2812221 force-pushed on Aug 29, 2018
  21. DrahtBot removed the label Needs rebase on Aug 29, 2018
  22. laanwj removed this from the "Blockers" column in a project

  23. 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
    b9babc82dd
  24. ken2812221 force-pushed on Aug 31, 2018
  25. ryanofsky commented at 10:34 pm on September 6, 2018: member
    utACK b9babc82dd6a0a4f6f623fcbe5330962eb37eccf
  26. ryanofsky approved
  27. laanwj commented at 7:02 am on September 11, 2018: member
    utACK b9babc82dd6a0a4f6f623fcbe5330962eb37eccf
  28. laanwj merged this on Sep 11, 2018
  29. laanwj closed this on Sep 11, 2018

  30. laanwj referenced this in commit 3783b139e9 on Sep 11, 2018
  31. ken2812221 deleted the branch on Sep 11, 2018
  32. deadalnix referenced this in commit 7fa094b10e on Nov 10, 2020
  33. kittywhiskers referenced this in commit 8faef695ba on May 19, 2021
  34. kittywhiskers referenced this in commit f7cf4578e6 on May 19, 2021
  35. kittywhiskers referenced this in commit 7546d16953 on May 20, 2021
  36. kittywhiskers referenced this in commit 7a3d581c4b on May 20, 2021
  37. kittywhiskers referenced this in commit 59d2834951 on May 20, 2021
  38. kittywhiskers referenced this in commit abffb58b5e on May 20, 2021
  39. PastaPastaPasta referenced this in commit b76e7fec1f on May 21, 2021
  40. random-zebra referenced this in commit 61a098a775 on Aug 5, 2021
  41. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 13:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me