Set encoding based on database encoding.