Python 2 Unicode strings can be used as inputs to char * or std::string types
Requires SWIG_PYTHON_2_UNICODE to be defined when compiling generated code.
This commit is contained in:
parent
291186cfaf
commit
01611702ec
5 changed files with 88 additions and 0 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
%include <std_string.i>
|
||||
|
||||
%begin %{
|
||||
#define SWIG_PYTHON_2_UNICODE
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
const char* non_utf8_c_str(void) {
|
||||
|
|
@ -12,4 +16,8 @@ std::string non_utf8_std_string(void) {
|
|||
return std::string("h\xe9llo w\xc3\xb6rld");
|
||||
}
|
||||
|
||||
char *charstring(char *s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue