diff options
author | Robin Krahl <me@robin-krahl.de> | 2019-01-13 12:05:28 +0100 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2019-01-13 13:27:31 +0100 |
commit | a80378e0c770a503ddaafc0c7aacb78cac667b8f (patch) | |
tree | 447e63e584b111f7271e55c64427edc126c57ec2 /device.cc | |
parent | 2c79c15dc9aa4ec7eca454b793bf43a9a3ba85db (diff) | |
download | libnitrokey-a80378e0c770a503ddaafc0c7aacb78cac667b8f.tar.gz libnitrokey-a80378e0c770a503ddaafc0c7aacb78cac667b8f.tar.bz2 |
Change std::wstring to std::string in DeviceInfo
For easier handling, we should use a std::string instead of
std::wstring for the serial number in DeviceInfo. For the conversion, I
assume that the serial number is valid UTF-8. As it should be
alphanumeric and ASCII only, this should be true.
Diffstat (limited to 'device.cc')
-rw-r--r-- | device.cc | 6 |
1 files changed, 5 insertions, 1 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); } |