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
1680e984
Commit
1680e984
authored
Nov 15, 2016
by
Piotr Caban
Committed by
Alexandre Julliard
Nov 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Improve multibyte characters support in printf.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
3fdfea77
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
6 deletions
+42
-6
printf.h
dlls/msvcrt/printf.h
+7
-5
printf.c
dlls/msvcrt/tests/printf.c
+35
-1
No files found.
dlls/msvcrt/printf.h
View file @
1680e984
...
...
@@ -122,13 +122,18 @@ static inline int FUNC_NAME(pf_output_wstr)(FUNC_NAME(puts_clbk) pf_puts, void *
return
pf_puts
(
puts_ctx
,
len
,
str
);
#else
LPSTR
out
;
int
len_a
=
WideCharToMultiByte
(
locinfo
->
lc_codepage
,
0
,
str
,
len
,
NULL
,
0
,
NULL
,
NULL
);
BOOL
def_char
;
int
len_a
=
WideCharToMultiByte
(
locinfo
->
lc_codepage
,
WC_NO_BEST_FIT_CHARS
,
str
,
len
,
NULL
,
0
,
NULL
,
&
def_char
);
if
(
def_char
)
return
0
;
out
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len_a
);
if
(
!
out
)
return
-
1
;
WideCharToMultiByte
(
locinfo
->
lc_codepage
,
0
,
str
,
len
,
out
,
len_a
,
NULL
,
NULL
);
WideCharToMultiByte
(
locinfo
->
lc_codepage
,
WC_NO_BEST_FIT_CHARS
,
str
,
len
,
out
,
len_a
,
NULL
,
NULL
);
len
=
pf_puts
(
puts_ctx
,
len_a
,
out
);
HeapFree
(
GetProcessHeap
(),
0
,
out
);
return
len
;
...
...
@@ -495,9 +500,6 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
}
else
if
(
flags
.
Format
==
'c'
||
flags
.
Format
==
'C'
)
{
int
ch
=
pf_args
(
args_ctx
,
pos
,
VT_INT
,
valist
).
get_int
;
if
((
ch
&
0xff
)
!=
ch
)
FIXME
(
"multibyte characters printing not supported
\n
"
);
i
=
FUNC_NAME
(
pf_handle_string
)(
pf_puts
,
puts_ctx
,
&
ch
,
1
,
&
flags
,
locinfo
,
legacy_wide
);
}
else
if
(
flags
.
Format
==
'p'
)
{
flags
.
Format
=
'X'
;
...
...
dlls/msvcrt/tests/printf.c
View file @
1680e984
...
...
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <errno.h>
#include <locale.h>
#include "windef.h"
#include "winbase.h"
...
...
@@ -768,6 +769,39 @@ static void test_sprintf( void )
r
=
sprintf
(
buffer
,
format
,
INFINITY
);
ok
(
r
==
10
,
"r = %d
\n
"
,
r
);
ok
(
!
strcmp
(
buffer
,
"0000001.#J"
),
"failed:
\"
%s
\"\n
"
,
buffer
);
format
=
"%c"
;
r
=
sprintf
(
buffer
,
format
,
'a'
);
ok
(
r
==
1
,
"r = %d
\n
"
,
r
);
ok
(
!
strcmp
(
buffer
,
"a"
),
"failed:
\"
%s
\"\n
"
,
buffer
);
r
=
sprintf
(
buffer
,
format
,
0xa082
);
ok
(
r
==
1
,
"r = %d
\n
"
,
r
);
ok
(
!
strcmp
(
buffer
,
"
\x82
"
),
"failed:
\"
%s
\"\n
"
,
buffer
);
format
=
"%C"
;
r
=
sprintf
(
buffer
,
format
,
'a'
);
ok
(
r
==
1
,
"r = %d
\n
"
,
r
);
ok
(
!
strcmp
(
buffer
,
"a"
),
"failed:
\"
%s
\"\n
"
,
buffer
);
r
=
sprintf
(
buffer
,
format
,
0x3042
);
ok
(
r
==
0
,
"r = %d
\n
"
,
r
);
ok
(
!
strcmp
(
buffer
,
""
),
"failed:
\"
%s
\"\n
"
,
buffer
);
if
(
!
setlocale
(
LC_ALL
,
"Japanese_Japan.932"
))
{
win_skip
(
"Japanese_Japan.932 locale not available
\n
"
);
return
;
}
format
=
"%c"
;
r
=
sprintf
(
buffer
,
format
,
0xa082
);
ok
(
r
==
1
,
"r = %d
\n
"
,
r
);
ok
(
!
strcmp
(
buffer
,
"
\x82
"
),
"failed:
\"
%s
\"\n
"
,
buffer
);
format
=
"%C"
;
r
=
sprintf
(
buffer
,
format
,
0x3042
);
ok
(
r
==
2
,
"r = %d
\n
"
,
r
);
ok
(
!
strcmp
(
buffer
,
"
\x82\xa0
"
),
"failed:
\"
%s
\"\n
"
,
buffer
);
setlocale
(
LC_ALL
,
"C"
);
}
static
void
test_swprintf
(
void
)
...
...
@@ -911,7 +945,7 @@ static void test_fcvt(void)
{
char
*
str
;
int
dec
=
100
,
sign
=
100
;
/* Numbers less than 1.0 with different precisions */
str
=
_fcvt
(
0
.
0001
,
1
,
&
dec
,
&
sign
);
ok
(
0
==
strcmp
(
str
,
""
),
"bad return '%s'
\n
"
,
str
);
...
...
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