aboutsummaryrefslogtreecommitdiff
path: root/src/base/Osx.cpp
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-10-17 21:50:24 +0800
committerYuqian Yang <crupest@crupest.life>2025-10-17 21:50:24 +0800
commit728d592f4075ae78b67dab6911ada05875a470a3 (patch)
tree57a7232ea0a984b0344bc63a593c1dee65072d2f /src/base/Osx.cpp
parent045462a6aed2796976a2f5cf0042f9a0ac1493f7 (diff)
downloadcru-728d592f4075ae78b67dab6911ada05875a470a3.tar.gz
cru-728d592f4075ae78b67dab6911ada05875a470a3.tar.bz2
cru-728d592f4075ae78b67dab6911ada05875a470a3.zip
Fix macOS build.
Diffstat (limited to 'src/base/Osx.cpp')
-rw-r--r--src/base/Osx.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/base/Osx.cpp b/src/base/Osx.cpp
index 46b923fe..d979f542 100644
--- a/src/base/Osx.cpp
+++ b/src/base/Osx.cpp
@@ -1,19 +1,22 @@
#include "cru/base/Osx.h"
+#include "cru/base/StringUtil.h"
namespace cru {
-CFWrapper<CFStringRef> ToCFString(StringView string) {
+CFWrapper<CFStringRef> ToCFString(std::string_view string) {
return CFWrapper<CFStringRef>(CFStringCreateWithBytes(
nullptr, reinterpret_cast<const UInt8*>(string.data()),
- string.size() * sizeof(std::uint16_t), kCFStringEncodingUTF16, false));
+ string.size() * sizeof(char), kCFStringEncodingUTF8, false));
}
-String FromCFStringRef(CFStringRef string) {
+std::string FromCFStringRef(CFStringRef string) {
auto length = CFStringGetLength(string);
- String result;
+ std::string result;
for (int i = 0; i < length; i++) {
- result.AppendCodePoint(CFStringGetCharacterAtIndex(string, i));
+ cru::string::Utf8EncodeCodePointAppend(
+ CFStringGetCharacterAtIndex(string, i),
+ [&result](char c) { result += c; });
}
return result;