public static function ensureUTF8($input)
    {
        $encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1'], true);

        if ('ISO-8859-1' === $encoding) {
            return utf8_encode($input);
        } else {
            return $input;
        }
    }