properly deal with multibyte characters, closes #33