Skip to content
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

utils: Convert Windows args to utf-8 string #13883

Merged
merged 1 commit into from Oct 8, 2018

Conversation

@ken2812221
Copy link
Contributor

@ken2812221 ken2812221 commented Aug 5, 2018

Create a new class WinCmdLineArgs when building for Windows. It converts all command line arguments to utf8 string.

@donaloconnor
Copy link
Contributor

@donaloconnor donaloconnor commented Aug 5, 2018

utACK f059e7a

@DrahtBot
Copy link
Contributor

@DrahtBot DrahtBot commented Aug 5, 2018

Reviewers, this pull request conflicts with the following ones:
  • #13746 (-masterdatadir for datadir bootstrapping by kallewoof)
  • #10102 ([experimental] Multiprocess bitcoin by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@alexeyneu
Copy link

@alexeyneu alexeyneu commented Aug 13, 2018

no-bowler
https://imageshack.com/a/img922/8836/nesafY.jpg

	std::wstring h;
	h=GetCommandLineW();

	std::wcout << h;

it's for wwinmain
UPD:
it's smth else here .
works only after setlocale(LC_ALL, "Portuguese_Portugal.1252"); with main/wmain no matter
(?)
upd2:

_setmode(_fileno(stdout), _O_U16TEXT);
std::wcout << L"curaçao";

seems to be only way. Will be handy when verbose log dubbed to stdout .not sure if btc wallet has this option but monero has smth like that

@@ -15,6 +15,7 @@
#include <util.h>
#include <utilstrencodings.h>

#include <tuple>
Copy link
Contributor

@practicalswift practicalswift Sep 11, 2018

src/bitcoin-cli.cpp:18:1: warning: #includes are not sorted properly [llvm-include-order]

@ken2812221 ken2812221 force-pushed the windows-command-line-args branch 2 times, most recently from c237745 to 1e23b1c Sep 11, 2018
@MarcoFalke
Copy link
Member

@MarcoFalke MarcoFalke commented Sep 11, 2018

1e23b1cba1645b50570e1b4ca4f2da03e000f732 is adding a binary file. Is that wanted?

@ken2812221 ken2812221 force-pushed the windows-command-line-args branch from 1e23b1c to 83a94ce Sep 11, 2018
@ken2812221
Copy link
Contributor Author

@ken2812221 ken2812221 commented Sep 11, 2018

@MarcoFalke Sorry, forgot to delete that

@@ -16,6 +16,7 @@
#include <utilstrencodings.h>

#include <memory>
#include <tuple>
Copy link
Contributor

@practicalswift practicalswift Sep 13, 2018

Minor nit:

2018-09-13 21:33:38 clang-tidy(pr=13883): src/bitcoin-cli.cpp:18:1: warning: #includes are not sorted properly [llvm-include-order]

Copy link
Contributor Author

@ken2812221 ken2812221 Sep 14, 2018

Would you prefer to put tuple after stdio.h? I think we should seperate C and C++ headers.

Copy link
Contributor

@practicalswift practicalswift Sep 14, 2018

I don't think we separate C and C++ headers elsewhere, but please sort them.

src/util.cpp Outdated
return std::make_pair(argc, argv);
}
#endif
}
Copy link
Contributor

@practicalswift practicalswift Sep 14, 2018

2018-09-13 21:33:38 clang-tidy(pr=13883): src/util.cpp:1290:2: warning: namespace 'util' not terminated with a closing comment [google-readability-namespace-comments]

@ken2812221 ken2812221 force-pushed the windows-command-line-args branch from 83a94ce to 3a45880 Sep 14, 2018
@ken2812221 ken2812221 force-pushed the windows-command-line-args branch 2 times, most recently from bcd6c40 to 8b4ed7e Sep 27, 2018
@ken2812221 ken2812221 force-pushed the windows-command-line-args branch from 8b4ed7e to 734343d Sep 28, 2018
@ken2812221 ken2812221 changed the title utils: Convert Windows args to utf-8 string [WIP] utils: Convert Windows args to utf-8 string Sep 28, 2018
@ken2812221 ken2812221 force-pushed the windows-command-line-args branch 2 times, most recently from e6924e8 to ac2a0b9 Sep 28, 2018
@ken2812221 ken2812221 force-pushed the windows-command-line-args branch 2 times, most recently from e3a641d to b0a81d3 Sep 28, 2018
@ken2812221 ken2812221 changed the title [WIP] utils: Convert Windows args to utf-8 string utils: Convert Windows args to utf-8 string Sep 28, 2018
@NicolasDorier
Copy link
Contributor

@NicolasDorier NicolasDorier commented Sep 30, 2018

Can you add a python test on this? You can probably highjack https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/test/functional/feature_uacomment.py by trying to set a chinese char.

@ken2812221 ken2812221 force-pushed the windows-command-line-args branch from b0a81d3 to 380c843 Sep 30, 2018
@MarcoFalke
Copy link
Member

@MarcoFalke MarcoFalke commented Oct 1, 2018

Concept ACK 380c843 (Only checked that this should only affect Windows. Didn't review nor checked that the tests fail without this fix on windows.)

@NicolasDorier
Copy link
Contributor

@NicolasDorier NicolasDorier commented Oct 1, 2018

tACK 380c843 . The test is breaking without the fix.

@MarcoFalke MarcoFalke added this to the 0.18.0 milestone Oct 1, 2018
MarcoFalke added a commit to MarcoFalke/bitcoin-core that referenced this issue Oct 8, 2018
380c843 utils: Convert Windows args to utf-8 string (Chun Kuan Lee)

Pull request description:

  Create a new class `WinCmdLineArgs` when building for Windows. It converts all command line arguments to utf8 string.

Tree-SHA512: f098520fd123a8a452bc84a55dc8c0b88f0c475410efe57f2ccc393f86c396eed59ea1575ddc1b920323792e390fdb092061d80cdcd9b682f0ac79a22a22ff82
@MarcoFalke MarcoFalke merged commit 380c843 into bitcoin:master Oct 8, 2018
2 checks passed
@ken2812221 ken2812221 deleted the windows-command-line-args branch Oct 8, 2018
Warrows added a commit to Warrows/PIVX that referenced this issue Oct 14, 2019
Backports bitcoin#13883

Create a new class WinCmdLineArgs when building for Windows. It converts
all command line arguments to utf8 string.
Warrows added a commit to Warrows/PIVX that referenced this issue Nov 23, 2019
Backports bitcoin#13883

Create a new class WinCmdLineArgs when building for Windows. It converts
all command line arguments to utf8 string.
random-zebra added a commit to PIVX-Project/PIVX that referenced this issue Aug 5, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants