aboutsummaryrefslogtreecommitdiff
path: root/src/base/Osx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/Osx.cpp')
-rw-r--r--src/base/Osx.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/base/Osx.cpp b/src/base/Osx.cpp
new file mode 100644
index 00000000..6b8d0bd9
--- /dev/null
+++ b/src/base/Osx.cpp
@@ -0,0 +1,21 @@
+#include "cru/base/Osx.h"
+
+namespace cru {
+CFWrapper<CFStringRef> ToCFStringRef(StringView string) {
+ return CFWrapper<CFStringRef>(CFStringCreateWithBytes(
+ nullptr, reinterpret_cast<const UInt8*>(string.data()),
+ string.size() * sizeof(std::uint16_t), kCFStringEncodingUTF16, false));
+}
+
+String FromCFStringRef(CFStringRef string) {
+ auto length = CFStringGetLength(string);
+
+ String result;
+
+ for (int i = 0; i < length; i++) {
+ result.AppendCodePoint(CFStringGetCharacterAtIndex(string, i));
+ }
+
+ return result;
+}
+} // namespace cru