Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
1be12eaa
Commit
1be12eaa
authored
Oct 06, 2021
by
Jacek Caban
Committed by
Alexandre Julliard
Oct 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Provide some Unicode helpers for Unix libs.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
65ce784f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
30 deletions
+71
-30
env.c
dlls/ntdll/unix/env.c
+71
-30
No files found.
dlls/ntdll/unix/env.c
View file @
1be12eaa
...
...
@@ -644,37 +644,11 @@ DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen )
}
else
/* utf-8 */
{
unsigned
int
res
;
const
char
*
srcend
=
src
+
srclen
;
WCHAR
*
dstend
=
dst
+
dstlen
;
while
((
dst
<
dstend
)
&&
(
src
<
srcend
))
{
unsigned
char
ch
=
*
src
++
;
if
(
ch
<
0x80
)
/* special fast case for 7-bit ASCII */
{
*
dst
++
=
ch
;
continue
;
}
if
((
res
=
decode_utf8_char
(
ch
,
&
src
,
srcend
))
<=
0xffff
)
{
*
dst
++
=
res
;
}
else
if
(
res
<=
0x10ffff
)
/* we need surrogates */
{
res
-=
0x10000
;
*
dst
++
=
0xd800
|
(
res
>>
10
);
if
(
dst
==
dstend
)
break
;
*
dst
++
=
0xdc00
|
(
res
&
0x3ff
);
}
else
{
*
dst
++
=
0xfffd
;
}
}
reslen
=
dstlen
-
(
dstend
-
dst
);
reslen
=
0
;
RtlUTF8ToUnicodeN
(
dst
,
dstlen
*
sizeof
(
WCHAR
),
&
reslen
,
src
,
srclen
);
reslen
/=
sizeof
(
WCHAR
);
#ifdef __APPLE__
/* work around broken Mac OS X filesystem that enforces NFD */
if
(
reslen
&&
nfc_table
)
reslen
=
compose_string
(
nfc_table
,
dst
-
reslen
,
reslen
);
if
(
reslen
&&
nfc_table
)
reslen
=
compose_string
(
nfc_table
,
dst
,
reslen
);
#endif
}
return
reslen
;
...
...
@@ -2486,3 +2460,70 @@ NTSTATUS WINAPI NtQueryInstallUILanguage( LANGID *lang )
*
lang
=
system_ui_language
;
return
STATUS_SUCCESS
;
}
WCHAR
WINAPI
RtlUpcaseUnicodeChar
(
WCHAR
wch
)
{
return
ntdll_towupper
(
wch
);
}
WCHAR
WINAPI
RtlDowncaseUnicodeChar
(
WCHAR
wch
)
{
return
ntdll_towlower
(
wch
);
}
NTSTATUS
WINAPI
RtlUTF8ToUnicodeN
(
WCHAR
*
dst
,
DWORD
dstlen
,
DWORD
*
reslen
,
const
char
*
src
,
DWORD
srclen
)
{
unsigned
int
res
,
len
;
NTSTATUS
status
=
STATUS_SUCCESS
;
const
char
*
srcend
=
src
+
srclen
;
WCHAR
*
dstend
;
if
(
!
src
)
return
STATUS_INVALID_PARAMETER_4
;
if
(
!
reslen
)
return
STATUS_INVALID_PARAMETER
;
dstlen
/=
sizeof
(
WCHAR
);
dstend
=
dst
+
dstlen
;
if
(
!
dst
)
{
for
(
len
=
0
;
src
<
srcend
;
len
++
)
{
unsigned
char
ch
=
*
src
++
;
if
(
ch
<
0x80
)
continue
;
if
((
res
=
decode_utf8_char
(
ch
,
&
src
,
srcend
))
>
0x10ffff
)
status
=
STATUS_SOME_NOT_MAPPED
;
else
if
(
res
>
0xffff
)
len
++
;
}
*
reslen
=
len
*
sizeof
(
WCHAR
);
return
status
;
}
while
((
dst
<
dstend
)
&&
(
src
<
srcend
))
{
unsigned
char
ch
=
*
src
++
;
if
(
ch
<
0x80
)
/* special fast case for 7-bit ASCII */
{
*
dst
++
=
ch
;
continue
;
}
if
((
res
=
decode_utf8_char
(
ch
,
&
src
,
srcend
))
<=
0xffff
)
{
*
dst
++
=
res
;
}
else
if
(
res
<=
0x10ffff
)
/* we need surrogates */
{
res
-=
0x10000
;
*
dst
++
=
0xd800
|
(
res
>>
10
);
if
(
dst
==
dstend
)
break
;
*
dst
++
=
0xdc00
|
(
res
&
0x3ff
);
}
else
{
*
dst
++
=
0xfffd
;
status
=
STATUS_SOME_NOT_MAPPED
;
}
}
if
(
src
<
srcend
)
status
=
STATUS_BUFFER_TOO_SMALL
;
/* overflow */
*
reslen
=
(
dstlen
-
(
dstend
-
dst
))
*
sizeof
(
WCHAR
);
return
status
;
}
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