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
0789ba68
Commit
0789ba68
authored
May 08, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed return value of wine_utf8_wcstombs (spotted by Jan Sporbeck).
parent
9914a8ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
utf8.c
libs/unicode/utf8.c
+6
-6
No files found.
libs/unicode/utf8.c
View file @
0789ba68
...
...
@@ -62,24 +62,24 @@ inline static int get_length_wcs_utf8( const WCHAR *src, unsigned int srclen )
/* return -1 on dst buffer overflow */
int
wine_utf8_wcstombs
(
const
WCHAR
*
src
,
int
srclen
,
char
*
dst
,
int
dstlen
)
{
int
ret
=
src
len
;
int
len
;
if
(
!
dstlen
)
return
get_length_wcs_utf8
(
src
,
srclen
);
for
(
ret
=
src
len
;
srclen
;
srclen
--
,
src
++
)
for
(
len
=
dst
len
;
srclen
;
srclen
--
,
src
++
)
{
WCHAR
ch
=
*
src
;
if
(
ch
<
0x80
)
/* 0x00-0x7f: 1 byte */
{
if
(
!
dst
len
--
)
return
-
1
;
/* overflow */
if
(
!
len
--
)
return
-
1
;
/* overflow */
*
dst
++
=
ch
;
continue
;
}
if
(
ch
<
0x800
)
/* 0x80-0x7ff: 2 bytes */
{
if
((
dst
len
-=
2
)
<
0
)
return
-
1
;
/* overflow */
if
((
len
-=
2
)
<
0
)
return
-
1
;
/* overflow */
dst
[
1
]
=
0x80
|
(
ch
&
0x3f
);
ch
>>=
6
;
dst
[
0
]
=
0xc0
|
ch
;
...
...
@@ -89,7 +89,7 @@ int wine_utf8_wcstombs( const WCHAR *src, int srclen, char *dst, int dstlen )
/* 0x800-0xffff: 3 bytes */
if
((
dst
len
-=
3
)
<
0
)
return
-
1
;
/* overflow */
if
((
len
-=
3
)
<
0
)
return
-
1
;
/* overflow */
dst
[
2
]
=
0x80
|
(
ch
&
0x3f
);
ch
>>=
6
;
dst
[
1
]
=
0x80
|
(
ch
&
0x3f
);
...
...
@@ -97,7 +97,7 @@ int wine_utf8_wcstombs( const WCHAR *src, int srclen, char *dst, int dstlen )
dst
[
0
]
=
0xe0
|
ch
;
dst
+=
3
;
}
return
ret
;
return
dstlen
-
len
;
}
/* query necessary dst length for src string */
...
...
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