improve charset handling