Various unicode related fixes (#226, #230, #251).
Merged pull-requests #252, #190 (manually).