Set encoding based on preferred encoding