如果要使用UTF-8的Encode,有两种方法:
一、将文件存为UTF-8文件,直接使用urlencode、rawurlencode即可。
二、使用mb_convert_encoding函数。
一、将文件存为UTF-8文件,直接使用urlencode、rawurlencode即可。
二、使用mb_convert_encoding函数。
- <?php
- $url = 'http://ud03.kinoko.name/中文.rar';
- echo urlencode(mb_convert_encoding($url, 'utf-8', 'gb2312'))."\n";
- echo rawurlencode(mb_convert_encoding($url, 'utf-8', 'gb2312'))."\n";
- //http%3A%2F%2Fud03.kinoko.name%2F%E4%B8%AD%E6%96%87.rar
- ?>