Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
65ff9cac
Commit
65ff9cac
authored
Apr 12, 2022
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32u: Use the ntdll functions for codepage conversions.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
6eae7a24
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
95 deletions
+9
-95
font.c
dlls/win32u/font.c
+7
-92
win32u_private.h
dlls/win32u/win32u_private.h
+2
-3
No files found.
dlls/win32u/font.c
View file @
65ff9cac
...
...
@@ -3221,7 +3221,6 @@ static UINT get_glyph_index_symbol( struct gdi_font *font, UINT glyph )
CPTABLEINFO
*
get_cptable
(
WORD
cp
)
{
static
CPTABLEINFO
tables
[
100
];
CPTABLEINFO
*
info
;
unsigned
int
i
;
USHORT
*
ptr
;
SIZE_T
size
;
...
...
@@ -3234,112 +3233,28 @@ CPTABLEINFO *get_cptable( WORD cp )
ERR
(
"too many code pages
\n
"
);
return
NULL
;
}
info
=
&
tables
[
i
];
info
->
CodePage
=
ptr
[
1
];
info
->
MaximumCharacterSize
=
ptr
[
2
];
info
->
DefaultChar
=
ptr
[
3
];
info
->
UniDefaultChar
=
ptr
[
4
];
info
->
TransDefaultChar
=
ptr
[
5
];
info
->
TransUniDefaultChar
=
ptr
[
6
];
memcpy
(
info
->
LeadByte
,
ptr
+
7
,
sizeof
(
info
->
LeadByte
)
);
ptr
+=
ptr
[
0
];
info
->
WideCharTable
=
ptr
+
ptr
[
0
]
+
1
;
info
->
MultiByteTable
=
++
ptr
;
ptr
+=
256
;
if
(
*
ptr
++
)
ptr
+=
256
;
/* glyph table */
info
->
DBCSRanges
=
ptr
;
if
(
*
ptr
)
/* dbcs ranges */
{
info
->
DBCSCodePage
=
1
;
info
->
DBCSOffsets
=
ptr
+
1
;
}
else
{
info
->
DBCSCodePage
=
0
;
info
->
DBCSOffsets
=
NULL
;
}
return
info
;
RtlInitCodePageTable
(
ptr
,
&
tables
[
i
]
);
return
&
tables
[
i
];
}
DWORD
win32u_wctomb
(
CPTABLEINFO
*
info
,
char
*
dst
,
DWORD
dstlen
,
const
WCHAR
*
src
,
DWORD
srclen
)
{
DWORD
i
,
ret
;
DWORD
ret
;
if
(
!
info
&&
!
(
info
=
get_cptable
(
get_acp
()
)))
return
0
;
srclen
/=
sizeof
(
WCHAR
);
if
(
info
->
DBCSCodePage
)
{
WCHAR
*
uni2cp
=
info
->
WideCharTable
;
for
(
i
=
dstlen
;
srclen
&&
i
;
i
--
,
srclen
--
,
src
++
)
{
if
(
uni2cp
[
*
src
]
&
0xff00
)
{
if
(
i
==
1
)
break
;
/* do not output a partial char */
i
--
;
*
dst
++
=
uni2cp
[
*
src
]
>>
8
;
}
*
dst
++
=
(
char
)
uni2cp
[
*
src
];
}
ret
=
dstlen
-
i
;
}
else
{
char
*
uni2cp
=
info
->
WideCharTable
;
ret
=
min
(
srclen
,
dstlen
);
for
(
i
=
0
;
i
<
ret
;
i
++
)
dst
[
i
]
=
uni2cp
[
src
[
i
]];
}
RtlUnicodeToCustomCPN
(
info
,
dst
,
dstlen
,
&
ret
,
src
,
srclen
);
return
ret
;
}
DWORD
win32u_mbtowc
(
CPTABLEINFO
*
info
,
WCHAR
*
dst
,
DWORD
dstlen
,
const
char
*
src
,
DWORD
srclen
)
{
DWORD
i
,
ret
;
DWORD
ret
;
if
(
!
info
&&
!
(
info
=
get_cptable
(
get_acp
()
)))
return
0
;
if
(
!
dst
)
{
/* only compute length */
if
(
info
->
DBCSOffsets
)
{
for
(
ret
=
0
;
srclen
--
;
src
++
,
ret
++
)
{
if
(
!
info
->
DBCSOffsets
[(
unsigned
char
)
*
src
])
continue
;
if
(
!
srclen
--
)
break
;
src
++
;
}
}
else
ret
=
srclen
;
return
ret
*
sizeof
(
WCHAR
);
}
dstlen
/=
sizeof
(
WCHAR
);
if
(
info
->
DBCSOffsets
)
{
for
(
i
=
dstlen
;
srclen
&&
i
;
i
--
,
srclen
--
,
src
++
,
dst
++
)
{
USHORT
off
=
info
->
DBCSOffsets
[(
unsigned
char
)
*
src
];
if
(
off
&&
srclen
>
1
)
{
src
++
;
srclen
--
;
*
dst
=
info
->
DBCSOffsets
[
off
+
(
unsigned
char
)
*
src
];
}
else
*
dst
=
info
->
MultiByteTable
[(
unsigned
char
)
*
src
];
}
ret
=
dstlen
-
i
;
}
else
{
ret
=
min
(
srclen
,
dstlen
);
for
(
i
=
0
;
i
<
ret
;
i
++
)
dst
[
i
]
=
info
->
MultiByteTable
[(
unsigned
char
)
src
[
i
]];
}
return
ret
*
sizeof
(
WCHAR
);
RtlCustomCPToUnicodeN
(
info
,
dst
,
dstlen
,
&
ret
,
src
,
srclen
);
return
ret
;
}
static
BOOL
wc_to_index
(
UINT
cp
,
WCHAR
wc
,
unsigned
char
*
dst
,
BOOL
allow_default
)
...
...
dlls/win32u/win32u_private.h
View file @
65ff9cac
...
...
@@ -592,9 +592,8 @@ static inline WCHAR *win32u_wcsdup( const WCHAR *str )
static
inline
WCHAR
*
towstr
(
const
char
*
str
)
{
DWORD
len
=
strlen
(
str
)
+
1
;
DWORD
size
=
win32u_mbtowc
(
NULL
,
NULL
,
0
,
str
,
len
);
WCHAR
*
ret
=
malloc
(
size
);
if
(
ret
)
win32u_mbtowc
(
NULL
,
ret
,
size
,
str
,
len
);
WCHAR
*
ret
=
malloc
(
len
*
sizeof
(
WCHAR
)
);
if
(
ret
)
win32u_mbtowc
(
NULL
,
ret
,
len
*
sizeof
(
WCHAR
),
str
,
len
);
return
ret
;
}
...
...
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