fix multi-byte issues

reference: http://blog.webfuns.net/archives/1710.html