blob: e5105698149258df65591d9ed04b4fe9c7902177 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "cru/common/platform/osx/Convert.hpp"
namespace cru::platform::osx {
CFStringRef Convert(const String& string) {
return CFStringCreateWithBytes(
nullptr, reinterpret_cast<const UInt8*>(string.data()),
string.size() * sizeof(std::uint16_t), kCFStringEncodingUTF16, false);
}
String Convert(CFStringRef string) {
auto length = CFStringGetLength(string);
String result;
for (int i = 0; i < length; i++) {
result.AppendCodePoint(CFStringGetCharacterAtIndex(string, i));
}
return result;
}
CFRange Convert(const Range& range) {
return CFRangeMake(range.position, range.count);
}
Range Convert(const CFRange& range) {
return Range(range.location, range.length);
}
} // namespace cru::platform::osx
|