diff options
| -rw-r--r-- | device.cc | 6 | ||||
| -rw-r--r-- | libnitrokey/device.h | 2 | ||||
| -rw-r--r-- | unittest/test_multiple_devices.cc | 10 | 
3 files changed, 10 insertions, 8 deletions
@@ -20,7 +20,9 @@   */  #include <chrono> +#include <codecvt>  #include <iostream> +#include <locale>  #include <thread>  #include <cstddef>  #include <stdexcept> @@ -210,7 +212,9 @@ std::vector<DeviceInfo> Device::enumerate(){      auto deviceModel = product_id_to_model(pInfo->product_id);      if (deviceModel.has_value()) {        std::string path(pInfo->path); -      std::wstring serialNumber(pInfo->serial_number); +      std::wstring serialNumberW(pInfo->serial_number); +      std::wstring_convert<std::codecvt_utf8<wchar_t>> converter; +      std::string serialNumber = converter.to_bytes(serialNumberW);        DeviceInfo info = { deviceModel.value(), path, serialNumber };        res.push_back(info);      } diff --git a/libnitrokey/device.h b/libnitrokey/device.h index 4b1c239..d50080d 100644 --- a/libnitrokey/device.h +++ b/libnitrokey/device.h @@ -92,7 +92,7 @@ struct DeviceInfo {      /**       * The serial number of the device.       */ -    std::wstring m_serialNumber; +    std::string m_serialNumber;  };  #include <atomic> diff --git a/unittest/test_multiple_devices.cc b/unittest/test_multiple_devices.cc index d644cfd..bc1b60b 100644 --- a/unittest/test_multiple_devices.cc +++ b/unittest/test_multiple_devices.cc @@ -42,9 +42,8 @@ TEST_CASE("List devices", "[BASIC]") {              std::cout << "Could not create device with model " << i.m_deviceModel << "\n";              continue;          } -        std::cout << i.m_deviceModel << " " << i.m_path << " "; -        std::wcout << i.m_serialNumber; -        std::cout << " |"; +        std::cout << i.m_deviceModel << " " << i.m_path << " " +          << i.m_serialNumber << " |";          d->set_path(i.m_path);          d->connect();          auto res = GetStatus::CommandTransaction::run(d); @@ -116,9 +115,8 @@ TEST_CASE("Use API", "[BASIC]") {      REQUIRE(v.size() > 0);      for (auto i : v) { -      std::cout << "Connect with: " << i.m_deviceModel << " " << i.m_path << " "; -      std::wcout << i.m_serialNumber; -      std::cout << " | " << std::boolalpha << nm->connect_with_path(i.m_path) << " |"; +      std::cout << "Connect with: " << i.m_deviceModel << " " << i.m_path << " " +        << i.m_serialNumber << " | " << std::boolalpha << nm->connect_with_path(i.m_path) << " |";        try {          auto status = nm->get_status();          std::cout << " " << status.card_serial_u32 << " "  | 
