diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-05-04 14:54:23 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-05-04 14:54:23 -0700 |
| commit | a94efe662b0537a606d40bdd4b986b5b2ea246e2 (patch) | |
| tree | f741d6b99225c7bda5fb7b349a1a5bf3ac50ab9d | |
| parent | f920d0e5208a75dcb14ac4fcb5b7c83edbaab861 (diff) | |
| download | vcpkg-a94efe662b0537a606d40bdd4b986b5b2ea246e2.tar.gz vcpkg-a94efe662b0537a606d40bdd4b986b5b2ea246e2.zip | |
Rename Strings:: function for utf8/utf16 conversion
| -rw-r--r-- | toolsrc/include/vcpkg_Strings.h | 4 | ||||
| -rw-r--r-- | toolsrc/src/PostBuildLint.cpp | 8 | ||||
| -rw-r--r-- | toolsrc/src/VcpkgCmdArguments.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/commands_export.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/commands_hash.cpp | 12 | ||||
| -rw-r--r-- | toolsrc/src/commands_portsdiff.cpp | 6 | ||||
| -rw-r--r-- | toolsrc/src/tests_paragraph.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg.cpp | 8 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Build.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Strings.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_System.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/vcpkglib.cpp | 2 |
12 files changed, 28 insertions, 30 deletions
diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index 11c8b5a6a..640c639ce 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -48,9 +48,9 @@ namespace vcpkg::Strings return details::wformat_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...); } - std::wstring utf8_to_utf16(const CStringView s); + std::wstring to_utf16(const CStringView s); - std::string utf16_to_utf8(const CWStringView w); + std::string to_utf8(const CWStringView w); std::string::const_iterator case_insensitive_ascii_find(const std::string& s, const std::string& pattern); diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp index 295a8a3b4..80c505122 100644 --- a/toolsrc/src/PostBuildLint.cpp +++ b/toolsrc/src/PostBuildLint.cpp @@ -297,7 +297,7 @@ namespace vcpkg::PostBuildLint Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", - Strings::utf16_to_utf8(cmd_line)); + Strings::to_utf8(cmd_line)); if (ec_data.output.find("ordinal hint RVA name") == std::string::npos) { @@ -334,7 +334,7 @@ namespace vcpkg::PostBuildLint Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", - Strings::utf16_to_utf8(cmd_line)); + Strings::to_utf8(cmd_line)); if (ec_data.output.find("App Container") == std::string::npos) { @@ -610,7 +610,7 @@ namespace vcpkg::PostBuildLint Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", - Strings::utf16_to_utf8(cmd_line)); + Strings::to_utf8(cmd_line)); for (const BuildType& bad_build_type : bad_build_types) { @@ -664,7 +664,7 @@ namespace vcpkg::PostBuildLint Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", - Strings::utf16_to_utf8(cmd_line)); + Strings::to_utf8(cmd_line)); for (const OutdatedDynamicCrt& outdated_crt : outdated_crts) { diff --git a/toolsrc/src/VcpkgCmdArguments.cpp b/toolsrc/src/VcpkgCmdArguments.cpp index 25f4c5582..733308cb0 100644 --- a/toolsrc/src/VcpkgCmdArguments.cpp +++ b/toolsrc/src/VcpkgCmdArguments.cpp @@ -48,7 +48,7 @@ namespace vcpkg std::vector<std::string> v; for (int i = 1; i < argc; ++i) { - v.push_back(Strings::utf16_to_utf8(argv[i])); + v.push_back(Strings::to_utf8(argv[i])); } return VcpkgCmdArguments::create_from_arg_sequence(v.data(), v.data() + v.size()); diff --git a/toolsrc/src/commands_export.cpp b/toolsrc/src/commands_export.cpp index 98bf00777..e46001b06 100644 --- a/toolsrc/src/commands_export.cpp +++ b/toolsrc/src/commands_export.cpp @@ -334,7 +334,7 @@ namespace vcpkg::Commands::Export "\n" " %s" "\n", - Strings::utf16_to_utf8(cmake_variable.s)); + Strings::to_utf8(cmake_variable.s)); }; if (raw) diff --git a/toolsrc/src/commands_hash.cpp b/toolsrc/src/commands_hash.cpp index 349c0e58f..0da2b031f 100644 --- a/toolsrc/src/commands_hash.cpp +++ b/toolsrc/src/commands_hash.cpp @@ -10,10 +10,8 @@ namespace vcpkg::Commands::Hash { auto cmd_line = Strings::wformat(LR"(CertUtil.exe -hashfile "%s" %s)", path.c_str(), hashType); auto ec_data = System::cmd_execute_and_capture_output(cmd_line); - Checks::check_exit(VCPKG_LINE_INFO, - ec_data.exit_code == 0, - "Running command:\n %s\n failed", - Strings::utf16_to_utf8(cmd_line)); + Checks::check_exit( + VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::to_utf8(cmd_line)); std::string const& output = ec_data.output; @@ -21,13 +19,13 @@ namespace vcpkg::Commands::Hash Checks::check_exit(VCPKG_LINE_INFO, start != std::string::npos, "Unexpected output format from command: %s", - Strings::utf16_to_utf8(cmd_line)); + Strings::to_utf8(cmd_line)); auto end = output.find_first_of("\r\n", start + 1); Checks::check_exit(VCPKG_LINE_INFO, end != std::string::npos, "Unexpected output format from command: %s", - Strings::utf16_to_utf8(cmd_line)); + Strings::to_utf8(cmd_line)); auto hash = output.substr(start, end - start); Util::erase_remove_if(hash, isspace); @@ -49,7 +47,7 @@ namespace vcpkg::Commands::Hash } if (args.command_arguments.size() == 2) { - do_file_hash(args.command_arguments[0], Strings::utf8_to_utf16(args.command_arguments[1])); + do_file_hash(args.command_arguments[0], Strings::to_utf16(args.command_arguments[1])); } Checks::exit_success(VCPKG_LINE_INFO); diff --git a/toolsrc/src/commands_portsdiff.cpp b/toolsrc/src/commands_portsdiff.cpp index 996d41f92..a614d654e 100644 --- a/toolsrc/src/commands_portsdiff.cpp +++ b/toolsrc/src/commands_portsdiff.cpp @@ -114,7 +114,7 @@ namespace vcpkg::Commands::PortsDiff Checks::check_exit(VCPKG_LINE_INFO, output.output == VALID_COMMIT_OUTPUT, "Invalid commit id %s", - Strings::utf16_to_utf8(git_commit_id)); + Strings::to_utf8(git_commit_id)); } void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) @@ -128,9 +128,9 @@ namespace vcpkg::Commands::PortsDiff const fs::path& git_exe = paths.get_git_exe(); - const std::wstring git_commit_id_for_previous_snapshot = Strings::utf8_to_utf16(args.command_arguments.at(0)); + const std::wstring git_commit_id_for_previous_snapshot = Strings::to_utf16(args.command_arguments.at(0)); const std::wstring git_commit_id_for_current_snapshot = - args.command_arguments.size() < 2 ? L"HEAD" : Strings::utf8_to_utf16(args.command_arguments.at(1)); + args.command_arguments.size() < 2 ? L"HEAD" : Strings::to_utf16(args.command_arguments.at(1)); check_commit_exists(git_exe, git_commit_id_for_current_snapshot); check_commit_exists(git_exe, git_commit_id_for_previous_snapshot); diff --git a/toolsrc/src/tests_paragraph.cpp b/toolsrc/src/tests_paragraph.cpp index de7a6d190..b66adc816 100644 --- a/toolsrc/src/tests_paragraph.cpp +++ b/toolsrc/src/tests_paragraph.cpp @@ -353,13 +353,13 @@ namespace UnitTest1 TEST_METHOD(utf8_to_utf16) { - auto str = vcpkg::Strings::utf8_to_utf16("abc"); + auto str = vcpkg::Strings::to_utf16("abc"); Assert::AreEqual(L"abc", str.c_str()); } TEST_METHOD(utf8_to_utf16_with_whitespace) { - auto str = vcpkg::Strings::utf8_to_utf16("abc -x86-windows"); + auto str = vcpkg::Strings::to_utf16("abc -x86-windows"); Assert::AreEqual(L"abc -x86-windows", str.c_str()); } }; diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index d24fad0e6..661d667bd 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -41,7 +41,7 @@ static void inner(const VcpkgCmdArguments& args) fs::path vcpkg_root_dir; if (args.vcpkg_root_dir != nullptr) { - vcpkg_root_dir = fs::stdfs::absolute(Strings::utf8_to_utf16(*args.vcpkg_root_dir)); + vcpkg_root_dir = fs::stdfs::absolute(Strings::to_utf16(*args.vcpkg_root_dir)); } else { @@ -85,7 +85,7 @@ static void inner(const VcpkgCmdArguments& args) System::get_environmental_variable(L"VCPKG_DEFAULT_TRIPLET"); if (auto v = vcpkg_default_triplet_env.get()) { - default_triplet = Triplet::from_canonical_name(Strings::utf16_to_utf8(*v)); + default_triplet = Triplet::from_canonical_name(Strings::to_utf8(*v)); } else { @@ -200,7 +200,7 @@ int wmain(const int argc, const wchar_t* const* const argv) Metrics::track_property("version", Commands::Version::version()); - const std::string trimmed_command_line = trim_path_from_command_line(Strings::utf16_to_utf8(GetCommandLineW())); + const std::string trimmed_command_line = trim_path_from_command_line(Strings::to_utf8(GetCommandLineW())); Metrics::track_property("cmdline", trimmed_command_line); loadConfig(); Metrics::track_property("sqmuser", Metrics::get_SQM_user()); @@ -247,6 +247,6 @@ int wmain(const int argc, const wchar_t* const* const argv) exc_msg); fflush(stdout); for (int x = 0; x < argc; ++x) - System::println("%s|", Strings::utf16_to_utf8(argv[x])); + System::println("%s|", Strings::to_utf8(argv[x])); fflush(stdout); } diff --git a/toolsrc/src/vcpkg_Build.cpp b/toolsrc/src/vcpkg_Build.cpp index c29f61468..1f201e4c7 100644 --- a/toolsrc/src/vcpkg_Build.cpp +++ b/toolsrc/src/vcpkg_Build.cpp @@ -35,7 +35,7 @@ namespace vcpkg::Build } return Strings::wformat( - LR"("%s" %s %s 2>&1)", toolset.vcvarsall.native(), Strings::utf8_to_utf16(triplet.architecture()), tonull); + LR"("%s" %s %s 2>&1)", toolset.vcvarsall.native(), Strings::to_utf16(triplet.architecture()), tonull); } static void create_binary_control_file(const VcpkgPaths& paths, diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp index 97f56e746..0d7fbe804 100644 --- a/toolsrc/src/vcpkg_Strings.cpp +++ b/toolsrc/src/vcpkg_Strings.cpp @@ -46,13 +46,13 @@ namespace vcpkg::Strings::details namespace vcpkg::Strings { - std::wstring utf8_to_utf16(const CStringView s) + std::wstring to_utf16(const CStringView s) { std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> conversion; return conversion.from_bytes(s); } - std::string utf16_to_utf8(const CWStringView w) + std::string to_utf8(const CWStringView w) { std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> conversion; return conversion.to_bytes(w); diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index abbed587c..e401e956e 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -97,7 +97,7 @@ namespace vcpkg::System // Basically we are wrapping it in quotes const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); - if (g_debugging) System::println("[DEBUG] _wspawnlpe(cmd.exe /c %s)", Strings::utf16_to_utf8(actual_cmd_line)); + if (g_debugging) System::println("[DEBUG] _wspawnlpe(cmd.exe /c %s)", Strings::to_utf8(actual_cmd_line)); auto exit_code = _wspawnlpe(_P_WAIT, L"cmd.exe", L"cmd.exe", L"/c", actual_cmd_line.c_str(), nullptr, env_cstr.data()); if (g_debugging) System::println("[DEBUG] _wspawnlpe() returned %d", exit_code); @@ -111,7 +111,7 @@ namespace vcpkg::System // Basically we are wrapping it in quotes const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); - if (g_debugging) System::println("[DEBUG] _wsystem(%s)", Strings::utf16_to_utf8(actual_cmd_line)); + if (g_debugging) System::println("[DEBUG] _wsystem(%s)", Strings::to_utf8(actual_cmd_line)); int exit_code = _wsystem(actual_cmd_line.c_str()); if (g_debugging) System::println("[DEBUG] _wsystem() returned %d", exit_code); return exit_code; diff --git a/toolsrc/src/vcpkglib.cpp b/toolsrc/src/vcpkglib.cpp index 001ce839e..15130f77e 100644 --- a/toolsrc/src/vcpkglib.cpp +++ b/toolsrc/src/vcpkglib.cpp @@ -219,7 +219,7 @@ namespace vcpkg { } CMakeVariable::CMakeVariable(const CWStringView varname, const std::string& varvalue) - : CMakeVariable(varname, Strings::utf8_to_utf16(varvalue).c_str()) + : CMakeVariable(varname, Strings::to_utf16(varvalue).c_str()) { } CMakeVariable::CMakeVariable(const CWStringView varname, const std::wstring& varvalue) |
