Fixed bugs, support 6 bytes utf-8 bytes. Added test cases.