fix chat problem with multi-byte characters

fix the problem that wrong length used when sending strings

also modify some packet variable name