fix bug in setting charset