This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author theller
Recipients collinwinter, loewis, nnorwitz, theller
Date 2008-03-25.22:41:56
SpamBayes Score 0.036816362
Marked as misclassified No
Message-id <47E97FC5.2070000@ctypes.org>
In-reply-to <47E8BB52.104@ctypes.org>
Content
Thomas Heller schrieb:
> Thomas Heller <theller@ctypes.org> added the comment:
> 
>> In the simplest case, convert
>> 
>> import dl
>> libc = dl.open("libc.so.6")
>> iconv = libc.call("iconv_open", "ISO-8859-1", "ISO-8859-2")
>> print(iconv)
>> 
>> to
>> 
>> import ctypes
>> libc = ctypes.CDLL("libc.so.6")
>> iconv = libc.iconv_open("ISO-8859-1", "ISO-8859-2")
>> print(iconv)
>> 

Currently, in py3k, ctypes only passed bytes objects as char*; so
the strings should be translated to bytes literals:

import ctypes
libc = ctypes.CDLL("libc.so.6")
iconv = libc.iconv_open(b"ISO-8859-1", b"ISO-8859-2")
#                       ^              ^
print(iconv)
History
Date User Action Args
2008-03-25 22:41:58thellersetspambayes_score: 0.0368164 -> 0.036816362
recipients: + theller, loewis, nnorwitz, collinwinter
2008-03-25 22:41:57thellerlinkissue2470 messages
2008-03-25 22:41:56thellercreate