Tests for Python Bytes/Unicode distinction
This commit is contained in:
parent
33edfa4a62
commit
17a4143dd0
3 changed files with 121 additions and 0 deletions
41
Examples/test-suite/python_strict_unicode.i
Normal file
41
Examples/test-suite/python_strict_unicode.i
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
%module python_strict_unicode
|
||||
|
||||
%include <std_string.i>
|
||||
%include <std_wstring.i>
|
||||
|
||||
%begin %{
|
||||
#define SWIG_PYTHON_STRICT_BYTE_CHAR
|
||||
#define SWIG_PYTHON_STRICT_UNICODE_WCHAR
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
std::string double_str(const std::string& in)
|
||||
{
|
||||
return in + in;
|
||||
}
|
||||
|
||||
char *same_str(char* in)
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
std::wstring double_wstr(const std::wstring& in)
|
||||
{
|
||||
return in + in;
|
||||
}
|
||||
|
||||
wchar_t *same_wstr(wchar_t* in)
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
std::wstring overload(const std::wstring& in)
|
||||
{
|
||||
return L"UNICODE";
|
||||
}
|
||||
|
||||
std::string overload(const std::string& in)
|
||||
{
|
||||
return "BYTES";
|
||||
}
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue