[C++-sig] python call C++'s unicode functions?

Roman Yakovenko roman.yakovenko at gmail.com
Sun Mar 19 12:36:20 CET 2006


On 3/19/06, Raul <ro4tub at gmail.com> wrote:
>
> void Foo(LPCWSTR str)
> {
>  MessageBoxW(NULL,str,L"Info",MB_OK);
> }
>
> BOOST_PYTHON_MODULE(dxui)
> {
>  def("Foo",Foo);
> }
>
> and i want to call the C++ function 'Foo' in the python scripts like that:
> #Python Scripts
> def Bar():
>    Foo(u"Hello World");
>
> and then i call the Python Function 'Bar' in the C++ source file.
>
> but i don't know how to conver the python 'unicode' type to LPCWSTR  (the
> same as
> const unsigned short *).

I see that you are already wrapping an other function. So may be you
can use std::wstring?
In this case it will work as is.

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list