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. ken2812221 cross-referenced this on Aug 3, 2018 from issue Filename and command line encoding issue on Windows by ken2812221
  5. DrahtBot commented at 7:37 PM on August 3, 2018: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->No more conflicts as of last run.

  6. DrahtBot cross-referenced this on Aug 3, 2018 from issue utils: drop boost::interprocess::file_lock by ken2812221
  7. DrahtBot cross-referenced this on Aug 3, 2018 from issue Move src/tinyformat.h to src/tinyformat/tinyformat.h by Empact
  8. DrahtBot cross-referenced this on Aug 3, 2018 from issue Include tinyformat as a subtree by Empact
  9. DrahtBot cross-referenced this on Aug 3, 2018 from issue Inline i64tostr and itostr by Empact
  10. DrahtBot cross-referenced this on Aug 3, 2018 from issue Test for Windows encoding issue by ken2812221
  11. DrahtBot cross-referenced this on Aug 3, 2018 from issue PSBT key path cleanups by sipa
  12. DrahtBot cross-referenced this on Aug 3, 2018 from issue Remove the boost/algorithm/string/case_conv.hpp dependency by l2a5b1
  13. DrahtBot cross-referenced this on Aug 3, 2018 from issue [bugfix] Fix encoding issue for Windows by ken2812221
  14. 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.

  15. 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 :)

  16. fanquake added the label Windows on Aug 4, 2018
  17. fanquake added the label Utils/log/libs on Aug 4, 2018
  18. 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?

  19. ken2812221 force-pushed on Aug 4, 2018
  20. ken2812221 force-pushed on Aug 5, 2018
  21. ken2812221 force-pushed on Aug 5, 2018
  22. ken2812221 force-pushed on Aug 5, 2018
  23. ken2812221 force-pushed on Aug 5, 2018
  24. ken2812221 commented at 3:30 PM on August 5, 2018: contributor

    Update: use std codecvt instead of custom converter.

  25. ken2812221 renamed this:
    utils: Use _wfopen and _wreopen on Windows
    utils: Use _wfopen and _wfreopen on Windows
    on Aug 16, 2018
  26. laanwj added this to the "Blockers" column in a project

  27. ken2812221 force-pushed on Aug 21, 2018
  28. DrahtBot added the label Needs rebase on Aug 29, 2018
  29. ken2812221 force-pushed on Aug 29, 2018
  30. DrahtBot removed the label Needs rebase on Aug 29, 2018
  31. laanwj removed this from the "Blockers" column in a project

  32. 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
  33. ken2812221 force-pushed on Aug 31, 2018
  34. ryanofsky cross-referenced this on Sep 5, 2018 from issue utils: Add fstream wrapper to allow to pass unicode filename on Windows by ken2812221
  35. ryanofsky commented at 10:34 PM on September 6, 2018: contributor

    utACK b9babc82dd6a0a4f6f623fcbe5330962eb37eccf

  36. ryanofsky approved
  37. laanwj commented at 7:02 AM on September 11, 2018: member

    utACK b9babc82dd6a0a4f6f623fcbe5330962eb37eccf

  38. laanwj merged this on Sep 11, 2018
  39. laanwj closed this on Sep 11, 2018

  40. laanwj referenced this in commit 3783b139e9 on Sep 11, 2018
  41. ken2812221 deleted the branch on Sep 11, 2018
  42. Bushstar cross-referenced this on Oct 11, 2018 from issue Updates from bitcoin/master by Bushstar
  43. deadalnix referenced this in commit 7fa094b10e on Nov 10, 2020
  44. kwvg referenced this in commit 8faef695ba on May 19, 2021
  45. kwvg referenced this in commit f7cf4578e6 on May 19, 2021
  46. kwvg referenced this in commit 7546d16953 on May 20, 2021
  47. kwvg referenced this in commit 7a3d581c4b on May 20, 2021
  48. kwvg referenced this in commit 59d2834951 on May 20, 2021
  49. kwvg referenced this in commit abffb58b5e on May 20, 2021
  50. PastaPastaPasta referenced this in commit b76e7fec1f on May 21, 2021
  51. furszy cross-referenced this on Jun 24, 2021 from issue Solve filename and command line encoding issues on Windows by furszy
  52. random-zebra referenced this in commit 61a098a775 on Aug 5, 2021
  53. bitcoin 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: 2026-05-20 06:55 UTC