From a80378e0c770a503ddaafc0c7aacb78cac667b8f Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sun, 13 Jan 2019 12:05:28 +0100 Subject: 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. --- device.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'device.cc') diff --git a/device.cc b/device.cc index 35aefca..bc42965 100644 --- a/device.cc +++ b/device.cc @@ -20,7 +20,9 @@ */ #include +#include #include +#include #include #include #include @@ -210,7 +212,9 @@ std::vector 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> converter; + std::string serialNumber = converter.to_bytes(serialNumberW); DeviceInfo info = { deviceModel.value(), path, serialNumber }; res.push_back(info); } -- cgit v1.2.1