Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rolf Eike Beer
KWSys
Commits
88165c5e
Commit
88165c5e
authored
11 years ago
by
Clinton Stimpson
Committed by
Brad King
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Encoding: Fix bug in kwsysEncoding_DupToNarrow.
Change-Id: I96564a95f1ee6111edc58bdd85a933ace7502a73
parent
ab6f8c36
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
EncodingC.c
+1
-1
1 addition, 1 deletion
EncodingC.c
testEncoding.cxx
+10
-1
10 additions, 1 deletion
testEncoding.cxx
with
11 additions
and
2 deletions
EncodingC.c
+
1
−
1
View file @
88165c5e
...
...
@@ -68,7 +68,7 @@ size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* str, size_t n)
char
*
kwsysEncoding_DupToNarrow
(
const
wchar_t
*
str
)
{
char
*
ret
=
NULL
;
size_t
length
=
kwsysEncoding_wcstombs
(
0
,
str
,
0
);
size_t
length
=
kwsysEncoding_wcstombs
(
0
,
str
,
0
)
+
1
;
if
(
length
>
0
)
{
ret
=
malloc
(
length
);
...
...
This diff is collapsed.
Click to expand it.
testEncoding.cxx
+
10
−
1
View file @
88165c5e
...
...
@@ -16,14 +16,18 @@
#endif
#include KWSYS_HEADER(Encoding.hxx)
#include KWSYS_HEADER(Encoding.h)
#include KWSYS_HEADER(ios/iostream)
#include
<locale.h>
#include
<string.h>
#include
<stdlib.h>
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
# include "Encoding.hxx.in"
# include "Encoding.h.in"
# include "kwsys_ios_iostream.h.in"
#endif
...
...
@@ -68,11 +72,16 @@ static int testHelloWorldEncoding()
std
::
cout
<<
str
<<
std
::
endl
;
std
::
wstring
wstr
=
kwsys
::
Encoding
::
ToWide
(
str
);
std
::
string
str2
=
kwsys
::
Encoding
::
ToNarrow
(
wstr
);
if
(
!
wstr
.
empty
()
&&
str
!=
str2
)
wchar_t
*
c_wstr
=
kwsysEncoding_DupToWide
(
str
.
c_str
());
char
*
c_str2
=
kwsysEncoding_DupToNarrow
(
c_wstr
);
if
(
!
wstr
.
empty
()
&&
(
str
!=
str2
||
strcmp
(
c_str2
,
str
.
c_str
())))
{
std
::
cout
<<
"converted string was different: "
<<
str2
<<
std
::
endl
;
std
::
cout
<<
"converted string was different: "
<<
c_str2
<<
std
::
endl
;
ret
++
;
}
free
(
c_wstr
);
free
(
c_str2
);
}
return
ret
;
}
...
...
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