Fix #8 and fix #12 by using utf8 and byte length operations