private function decodeFilePath()

in src/OSS/OssClient.php [3558:3581]


    private function decodeFilePath($filepath)
    {
        if ($this->filePathCompatible !== true) {
            return $filepath;
        }
        if (empty($filepath)) {
            return $filepath;
        }

        try {
            $encoding = array('UTF-8', 'GB2312', 'GBK');
            $encode = mb_detect_encoding($filepath, $encoding);
            if ($encode === 'UTF-8' || $encode === false) {
                return $filepath;
            }
            $tmp = iconv($encode, 'UTF-8', $filepath);
            if ($tmp !== false) {
                $filepath = $tmp;
            }
        } catch (\Exception $e) {
            //IGNORE
        }
        return $filepath;
    }