Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glfw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pirvi-public
glfw
Commits
7f0d5e0a
Commit
7f0d5e0a
authored
7 years ago
by
Camilla Löwy
Browse files
Options
Downloads
Patches
Plain Diff
Win32: Fix text conversion size semantics
parent
f8668c5a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/win32_init.c
+10
-10
10 additions, 10 deletions
src/win32_init.c
with
10 additions
and
10 deletions
src/win32_init.c
+
10
−
10
View file @
7f0d5e0a
...
...
@@ -357,19 +357,19 @@ static HWND createHelperWindow(void)
WCHAR
*
_glfwCreateWideStringFromUTF8Win32
(
const
char
*
source
)
{
WCHAR
*
target
;
int
length
;
int
count
;
length
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
source
,
-
1
,
NULL
,
0
);
if
(
!
length
)
count
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
source
,
-
1
,
NULL
,
0
);
if
(
!
count
)
{
_glfwInputErrorWin32
(
GLFW_PLATFORM_ERROR
,
"Win32: Failed to convert string from UTF-8"
);
return
NULL
;
}
target
=
calloc
(
length
,
sizeof
(
WCHAR
));
target
=
calloc
(
count
,
sizeof
(
WCHAR
));
if
(
!
MultiByteToWideChar
(
CP_UTF8
,
0
,
source
,
-
1
,
target
,
length
))
if
(
!
MultiByteToWideChar
(
CP_UTF8
,
0
,
source
,
-
1
,
target
,
count
))
{
_glfwInputErrorWin32
(
GLFW_PLATFORM_ERROR
,
"Win32: Failed to convert string from UTF-8"
);
...
...
@@ -385,19 +385,19 @@ WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
char
*
_glfwCreateUTF8FromWideStringWin32
(
const
WCHAR
*
source
)
{
char
*
target
;
int
length
;
int
size
;
length
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
source
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
!
length
)
size
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
source
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
!
size
)
{
_glfwInputErrorWin32
(
GLFW_PLATFORM_ERROR
,
"Win32: Failed to convert string to UTF-8"
);
return
NULL
;
}
target
=
calloc
(
length
,
1
);
target
=
calloc
(
size
,
1
);
if
(
!
WideCharToMultiByte
(
CP_UTF8
,
0
,
source
,
-
1
,
target
,
length
,
NULL
,
NULL
))
if
(
!
WideCharToMultiByte
(
CP_UTF8
,
0
,
source
,
-
1
,
target
,
size
,
NULL
,
NULL
))
{
_glfwInputErrorWin32
(
GLFW_PLATFORM_ERROR
,
"Win32: Failed to convert string to UTF-8"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment