summaryrefslogtreecommitdiffstats
path: root/sandbox/src/sandbox_utils.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/src/sandbox_utils.cc')
-rw-r--r--sandbox/src/sandbox_utils.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/sandbox/src/sandbox_utils.cc b/sandbox/src/sandbox_utils.cc
index 315ba62..5c2688e 100644
--- a/sandbox/src/sandbox_utils.cc
+++ b/sandbox/src/sandbox_utils.cc
@@ -98,5 +98,22 @@ void InitObjectAttribs(const std::wstring& name, ULONG attributes, HANDLE root,
InitializeObjectAttributes(obj_attr, uni_name, attributes, root, NULL);
}
+std::string WideToMultiByte(const std::wstring& wide) {
+ if (wide.length() == 0)
+ return std::string();
+
+ // compute the length of the buffer we'll need
+ int charcount = WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1,
+ NULL, 0, NULL, NULL);
+ if (charcount == 0)
+ return std::string();
+
+ std::string mb;
+ WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1,
+ WriteInto(&mb, charcount), charcount, NULL, NULL);
+
+ return mb;
+}
+
}; // namespace sandbox