fix a bug about encoding