fix bug in string encoding