Provided an encoding function as well.