CoreFoundation: selectable charset on cfstring creation
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
9375e22ced
commit
25463aa5fc
@ -82,14 +82,14 @@ namespace macstd {
|
|||||||
public:
|
public:
|
||||||
cfstring(CFStringRef h) : cfobject<CFStringRef>(h) {}
|
cfstring(CFStringRef h) : cfobject<CFStringRef>(h) {}
|
||||||
|
|
||||||
cfstring(const char *s) : cfobject<CFStringRef>(CFStringCreateWithCString(kCFAllocatorDefault, s, kCFStringEncodingUTF8))
|
cfstring(const char *s, CFStringEncoding encoding = kCFStringEncodingUTF8) : cfobject<CFStringRef>(CFStringCreateWithCString(kCFAllocatorDefault, s, encoding))
|
||||||
{
|
{
|
||||||
if (!valid()) [[unlikely]]
|
if (!valid()) [[unlikely]]
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename TR, typename A>
|
template <typename TR, typename A>
|
||||||
cfstring(const std::basic_string<char, TR, A> &s) : cfstring(s.c_str()) {}
|
cfstring(const std::basic_string<char, TR, A> &s, CFStringEncoding encoding = kCFStringEncodingUTF8) : cfstring(s.c_str(), encoding) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user