correct handling of UTF-8 input

Please see https://phab.qadevel.cloud.fedoraproject.org/T293