Saturday, May 10, 2014

Python 3 Strings and ctypes

I was playing around with ctypes on Python 3, when I noticed something weird. Attempting to pass a regular Python string, which from what I understand is a utf8 string, it just didn't work. Functions like printf or anything that took a string just didn't cooperate with it. After some reading, I found a solution. Unfortunately I don't know enough of the ins and outs to explain it, but it seems to only accept a byte string (b""). So it was easily fixed by passing the string with str.encode("utf8").

Tag Cloud

.NET (1) A+ (1) addon (6) Android (3) anonymous functions (5) application (9) arduino (1) artificial intelligence (2) bash (3) c (7) camera (1) certifications (1) cobol (1) comptia (2) computing (2) css (2) customize (15) encryption (2) error (15) exploit (13) ftp (2) gadget (2) games (2) Gtk (1) GUI (5) hardware (6) haskell (15) help (5) HTML (4) irc (1) java (5) javascript (20) Linux (18) Mac (4) malware (1) math (8) network (5) objects (2) OCaml (1) perl (4) php (8) plugin (6) programming (42) python (24) radio (1) regex (3) security (21) sound (1) speakers (1) ssh (1) telnet (1) tools (11) troubleshooting (1) Ubuntu (3) Unix (4) virtualization (1) web design (14) Windows (6) wx (2)