Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
6274740d
Commit
6274740d
authored
Dec 05, 2013
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a concept of an 8 bit string class for testing and experimentation.
parent
45cd2756
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
UTF8.cpp
tools/UTF8.cpp
+73
-0
No files found.
tools/UTF8.cpp
0 → 100644
View file @
6274740d
#include <stdio.h>
#include <string>
#include <wx/string.h>
/**
* Class UTF8
* is an 8 bit std::string assuredly encoded in UTF8 that supplies special
* conversion support to and from wxString.
*/
class
UTF8
:
public
std
::
string
{
public
:
UTF8
(
const
wxString
&
o
)
:
std
::
string
(
(
const
char
*
)
o
.
utf8_str
()
)
{
}
UTF8
(
const
char
*
txt
)
:
std
::
string
(
txt
)
{
}
UTF8
(
const
std
::
string
&
o
)
:
std
::
string
(
o
)
{
}
UTF8
()
:
std
::
string
()
{
}
UTF8
&
operator
=
(
const
wxString
&
o
)
{
std
::
string
::
operator
=
(
(
const
char
*
)
o
.
utf8_str
()
);
}
operator
wxString
()
const
{
return
wxString
(
c_str
(),
wxConvUTF8
);
}
};
void
aFunctionTaking_wxString
(
const
wxString
&
wx
)
{
printf
(
"%s: '%s'
\n
"
,
__func__
,
UTF8
(
wx
).
c_str
()
);
}
int
main
()
{
UTF8
utf
;
std
::
string
str
=
"input"
;
wxString
wx
=
wxT
(
"input"
);
utf
=
str
;
wxString
wx2
=
utf
;
UTF8
utf2
=
wx2
;
printf
(
"here is some text:%s
\n
"
,
utf2
.
c_str
()
);
// this is the key accomplishment here, passing a UTF8 to a function taking wxString:
aFunctionTaking_wxString
(
utf2
);
return
0
;
}
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