Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
djinni
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
djinni
Commits
896aacb3
Commit
896aacb3
authored
Sep 06, 2017
by
Josh Gustafson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CFStringEncoding/NSStringEncoding confusion
parent
d8ef452e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
support-lib/objc/DJIMarshal+Private.h
support-lib/objc/DJIMarshal+Private.h
+4
-4
No files found.
support-lib/objc/DJIMarshal+Private.h
View file @
896aacb3
...
...
@@ -119,14 +119,14 @@ struct String {
};
template
<
int
wcharTypeSize
>
static
CF
StringEncoding
getWCharEncoding
()
static
NS
StringEncoding
getWCharEncoding
()
{
static_assert
(
wcharTypeSize
==
2
||
wcharTypeSize
==
4
,
"wchar_t must be represented by UTF-16 or UTF-32 encoding"
);
return
{};
// unreachable
}
template
<
>
inline
CF
StringEncoding
getWCharEncoding
<
2
>
()
{
inline
NS
StringEncoding
getWCharEncoding
<
2
>
()
{
// case when wchar_t is represented by utf-16 encoding
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
return
NSUTF16BigEndianStringEncoding
;
...
...
@@ -136,7 +136,7 @@ inline CFStringEncoding getWCharEncoding<2>() {
}
template
<
>
inline
CF
StringEncoding
getWCharEncoding
<
4
>
()
{
inline
NS
StringEncoding
getWCharEncoding
<
4
>
()
{
// case when wchar_t is represented by utf-32 encoding
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
return
NSUTF32BigEndianStringEncoding
;
...
...
@@ -153,7 +153,7 @@ struct WString {
static
CppType
toCpp
(
ObjcType
string
)
{
assert
(
string
);
NSStringEncoding
encoding
=
CFStringConvertEncodingToNSStringEncoding
(
getWCharEncoding
<
sizeof
(
wchar_t
)
>
()
);
NSStringEncoding
encoding
=
getWCharEncoding
<
sizeof
(
wchar_t
)
>
(
);
NSData
*
data
=
[
string
dataUsingEncoding
:
encoding
];
return
std
::
wstring
((
wchar_t
*
)[
data
bytes
],
[
data
length
]
/
sizeof
(
wchar_t
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment