2010-05-08から1日間の記事一覧

python3の文字列

python2から3で unicode -> str str -> bytesに変わってswigでのstd::stringの中身がutf-8決め打ちになっている。 http://docs.python.org/py3k/c-api/unicode.htmlswigのhoge_wrap.cpp #if PY_VERSION_HEX >= 0x03000000 return PyUnicode_FromStringAndSiz…

python3向けのエクステンションを作る

python2向けと同じ手順で準備してsetup.pyをpython3で実行するだけ。 python2とpytnon3の両方にパスを通してpython3のpython.exeをpython3.exeにリネームしておいた。 $ python3 setup.py build これでblender2.5向けに使える。 python3向けにするのに-py3と…

std::vectorがどうなっているか

vertices.h #include <vector> struct Vertex { float x; float y; float z; }; struct Container { std::vector<Vertex> vertices; }; に対してswigインターフェース vertices.i %module vertices %{ #include "vertices.h" %} %include "vertices.h" %include "std_vector.</vertex></vector>…

スクリプトで日本語パスが扱えない?

alpha2だが、 日本語が入っているパスだと文字化けするのみならずエラーが出て動作しないっぽい。 UnicodeDecodeError: 'utf8' codec can't decode byte 0x90 in position 24: unexpected code byteこれはたぶん、python3のstrがutf-8を仮定しているのにファ…