Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1243)

Unified Diff: device/udev_linux/udev.cc

Issue 989913002: Move UdevDecodeString from media/midi to device/udev_linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@seq3
Patch Set: Fix unit tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/udev_linux/udev.h ('k') | device/udev_linux/udev_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/udev_linux/udev.cc
diff --git a/device/udev_linux/udev.cc b/device/udev_linux/udev.cc
index a3fc0e941b2b4bab43dcfee1d46c279403faa90e..65686dade2af5c26d8bae4f34b6bee01af4412a2 100644
--- a/device/udev_linux/udev.cc
+++ b/device/udev_linux/udev.cc
@@ -4,6 +4,7 @@
#include "device/udev_linux/udev.h"
+#include "base/strings/string_util.h"
#include "device/udev_linux/udev_loader.h"
namespace device {
@@ -152,4 +153,19 @@ std::string UdevDeviceGetPropertyValue(udev_device* udev_device,
return value ? value : std::string();
}
+std::string UdevDecodeString(const std::string& encoded) {
+ std::string decoded;
+ const size_t size = encoded.size();
+ for (size_t i = 0; i < size; ++i) {
+ char c = encoded[i];
+ if ((i + 3 < size) && c == '\\' && encoded[i + 1] == 'x') {
+ c = (HexDigitToInt(encoded[i + 2]) << 4) +
+ HexDigitToInt(encoded[i + 3]);
+ i += 3;
+ }
+ decoded.push_back(c);
+ }
+ return decoded;
+}
+
} // namespace device
« no previous file with comments | « device/udev_linux/udev.h ('k') | device/udev_linux/udev_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698