formatting: return encoding as well.