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
dd572e9a
Commit
dd572e9a
authored
Dec 03, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Reimplement Unicode to multibyte conversion functions using the Win32-format tables.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e13c4d85
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
86 deletions
+67
-86
locale.c
dlls/ntdll/locale.c
+67
-0
rtlstr.c
dlls/ntdll/rtlstr.c
+0
-86
No files found.
dlls/ntdll/locale.c
View file @
dd572e9a
...
...
@@ -121,6 +121,21 @@ static DWORD mbtowc_size( const CPTABLEINFO *info, LPCSTR str, UINT len )
}
static
DWORD
wctomb_size
(
const
CPTABLEINFO
*
info
,
LPCWSTR
str
,
UINT
len
)
{
if
(
info
->
DBCSCodePage
)
{
WCHAR
*
uni2cp
=
info
->
WideCharTable
;
DWORD
res
;
for
(
res
=
0
;
len
;
len
--
,
str
++
,
res
++
)
if
(
uni2cp
[
*
str
]
&
0xff00
)
res
++
;
return
res
;
}
else
return
len
;
}
static
WCHAR
casemap
(
USHORT
*
table
,
WCHAR
ch
)
{
return
ch
+
table
[
table
[
table
[
ch
>>
8
]
+
((
ch
>>
4
)
&
0x0f
)]
+
(
ch
&
0x0f
)];
...
...
@@ -935,6 +950,58 @@ DWORD WINAPI RtlOemStringToUnicodeSize( const STRING *str )
/**************************************************************************
* RtlUnicodeStringToOemSize (NTDLL.@)
* RtlxUnicodeStringToOemSize (NTDLL.@)
*/
DWORD
WINAPI
RtlUnicodeStringToOemSize
(
const
UNICODE_STRING
*
str
)
{
return
wctomb_size
(
&
nls_info
.
OemTableInfo
,
str
->
Buffer
,
str
->
Length
/
sizeof
(
WCHAR
)
)
+
1
;
}
/**************************************************************************
* RtlUnicodeToMultiByteN (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlUnicodeToMultiByteN
(
char
*
dst
,
DWORD
dstlen
,
DWORD
*
reslen
,
const
WCHAR
*
src
,
DWORD
srclen
)
{
if
(
nls_info
.
AnsiTableInfo
.
WideCharTable
)
return
RtlUnicodeToCustomCPN
(
&
nls_info
.
AnsiTableInfo
,
dst
,
dstlen
,
reslen
,
src
,
srclen
);
/* locale not setup yet */
dstlen
=
min
(
srclen
/
sizeof
(
WCHAR
),
dstlen
);
if
(
reslen
)
*
reslen
=
dstlen
;
while
(
dstlen
--
)
{
WCHAR
ch
=
*
src
++
;
if
(
ch
>
0x7f
)
ch
=
'?'
;
*
dst
++
=
ch
;
}
return
STATUS_SUCCESS
;
}
/**************************************************************************
* RtlUnicodeToMultiByteSize (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlUnicodeToMultiByteSize
(
DWORD
*
size
,
const
WCHAR
*
str
,
DWORD
len
)
{
*
size
=
wctomb_size
(
&
nls_info
.
AnsiTableInfo
,
str
,
len
/
sizeof
(
WCHAR
)
);
return
STATUS_SUCCESS
;
}
/**************************************************************************
* RtlUnicodeToOemN (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlUnicodeToOemN
(
char
*
dst
,
DWORD
dstlen
,
DWORD
*
reslen
,
const
WCHAR
*
src
,
DWORD
srclen
)
{
return
RtlUnicodeToCustomCPN
(
&
nls_info
.
OemTableInfo
,
dst
,
dstlen
,
reslen
,
src
,
srclen
);
}
/**************************************************************************
* RtlUpcaseUnicodeToCustomCPN (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlUpcaseUnicodeToCustomCPN
(
CPTABLEINFO
*
info
,
char
*
dst
,
DWORD
dstlen
,
DWORD
*
reslen
,
...
...
dlls/ntdll/rtlstr.c
View file @
dd572e9a
...
...
@@ -40,11 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
#define GUID_STRING_LENGTH 38
extern
const
union
cptable
cptable_20127
;
/* 7-bit ASCII */
static
const
union
cptable
*
ansi_table
=
&
cptable_20127
;
static
const
union
cptable
*
oem_table
=
&
cptable_20127
;
/**************************************************************************
* __wine_init_codepages (NTDLL.@)
...
...
@@ -53,8 +48,6 @@ static const union cptable *oem_table = &cptable_20127;
*/
void
CDECL
__wine_init_codepages
(
const
union
cptable
*
ansi
,
const
union
cptable
*
oem
)
{
ansi_table
=
ansi
;
oem_table
=
oem
;
}
/**************************************************************************
...
...
@@ -774,44 +767,6 @@ NTSTATUS WINAPI RtlUnicodeStringToOemString( STRING *oem,
/**************************************************************************
* RtlUnicodeToMultiByteN (NTDLL.@)
*
* Converts a Unicode string to a multi-byte string in the ANSI code page.
*
* RETURNS
* NTSTATUS code
*/
NTSTATUS
WINAPI
RtlUnicodeToMultiByteN
(
LPSTR
dst
,
DWORD
dstlen
,
LPDWORD
reslen
,
LPCWSTR
src
,
DWORD
srclen
)
{
int
ret
=
wine_cp_wcstombs
(
ansi_table
,
0
,
src
,
srclen
/
sizeof
(
WCHAR
),
dst
,
dstlen
,
NULL
,
NULL
);
if
(
reslen
)
*
reslen
=
(
ret
>=
0
)
?
ret
:
dstlen
;
/* overflow -> we filled up to dstlen */
return
STATUS_SUCCESS
;
}
/**************************************************************************
* RtlUnicodeToOemN (NTDLL.@)
*
* Converts a Unicode string to a multi-byte string in the OEM code page.
*
* RETURNS
* NTSTATUS code
*/
NTSTATUS
WINAPI
RtlUnicodeToOemN
(
LPSTR
dst
,
DWORD
dstlen
,
LPDWORD
reslen
,
LPCWSTR
src
,
DWORD
srclen
)
{
int
ret
=
wine_cp_wcstombs
(
oem_table
,
0
,
src
,
srclen
/
sizeof
(
WCHAR
),
dst
,
dstlen
,
NULL
,
NULL
);
if
(
reslen
)
*
reslen
=
(
ret
>=
0
)
?
ret
:
dstlen
;
/* overflow -> we filled up to dstlen */
return
STATUS_SUCCESS
;
}
/**************************************************************************
* RtlUnicodeToUTF8N (NTDLL.@)
*
* Converts a Unicode string to a UTF-8 string.
...
...
@@ -1206,27 +1161,6 @@ DWORD WINAPI RtlAnsiStringToUnicodeSize( const STRING *str )
/**************************************************************************
* RtlUnicodeToMultiByteSize (NTDLL.@)
*
* Calculate the size in bytes necessary for the multibyte conversion of str,
* without the terminating '\0'.
*
* PARAMS
* size [O] Destination for size
* str [I] String to calculate the size of
* len [I] Length of str
*
* RETURNS
* STATUS_SUCCESS.
*/
NTSTATUS
WINAPI
RtlUnicodeToMultiByteSize
(
PULONG
size
,
LPCWSTR
str
,
ULONG
len
)
{
*
size
=
wine_cp_wcstombs
(
ansi_table
,
0
,
str
,
len
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
return
STATUS_SUCCESS
;
}
/**************************************************************************
* RtlUnicodeStringToAnsiSize (NTDLL.@)
* RtlxUnicodeStringToAnsiSize (NTDLL.@)
*
...
...
@@ -1248,26 +1182,6 @@ DWORD WINAPI RtlUnicodeStringToAnsiSize( const UNICODE_STRING *str )
/**************************************************************************
* RtlUnicodeStringToOemSize (NTDLL.@)
* RtlxUnicodeStringToOemSize (NTDLL.@)
*
* Calculate the size in bytes necessary for the OEM conversion of str,
* including the terminating '\0'.
*
* PARAMS
* str [I] String to calculate the size of
*
* RETURNS
* The calculated size.
*/
DWORD
WINAPI
RtlUnicodeStringToOemSize
(
const
UNICODE_STRING
*
str
)
{
return
wine_cp_wcstombs
(
oem_table
,
0
,
str
->
Buffer
,
str
->
Length
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
)
+
1
;
}
/**************************************************************************
* RtlAppendAsciizToString (NTDLL.@)
*
* Concatenates a buffered character string and a '\0' terminated character
...
...
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