Correction after PR revue of RobLoach.
Use 'utf8' for IO operations but use 'UTF-8' for value of encoding parameters.