Ensure to set encoding before returning