aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg_System.cpp
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-09-01 16:26:52 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-09-01 16:32:29 -0700
commit97063965b06280025eb123347f0145d6d817a29f (patch)
tree7f72cbb51e07610f5cd23c51e3a7af05f69e4719 /toolsrc/src/vcpkg_System.cpp
parentf0d5d94348a95c502688816c3ab360cd087aca95 (diff)
downloadvcpkg-97063965b06280025eb123347f0145d6d817a29f.tar.gz
vcpkg-97063965b06280025eb123347f0145d6d817a29f.zip
Remove #1712 workaround. Clean Byte-Order-Mark if present
Diffstat (limited to 'toolsrc/src/vcpkg_System.cpp')
-rw-r--r--toolsrc/src/vcpkg_System.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp
index beaa997b8..40e335117 100644
--- a/toolsrc/src/vcpkg_System.cpp
+++ b/toolsrc/src/vcpkg_System.cpp
@@ -176,6 +176,17 @@ namespace vcpkg::System
return exit_code;
}
+ // On Win7, output from powershell calls contain a byte order mark, so we strip it out if it is present
+ static void remove_byte_order_mark(std::wstring* s)
+ {
+ const wchar_t* a = s->c_str();
+ // This is the UTF-8 byte-order mark
+ if (a[0] == 0xEF && a[1] == 0xBB && a[2] == 0xBF)
+ {
+ s->erase(0, 3);
+ }
+ }
+
ExitCodeAndOutput cmd_execute_and_capture_output(const CWStringView cmd_line)
{
// Flush stdout before launching external process
@@ -202,6 +213,7 @@ namespace vcpkg::System
const auto ec = _pclose(pipe);
Debug::println("_pclose() returned %d", ec);
+ remove_byte_order_mark(&output);
return {ec, Strings::to_utf8(output)};
}