这是怎么工作的?
copy("http://translate.google.com/translate_tts?tl=en&q=Love+Me", "/directory/loveme.mp3");但这不是吗?
copy("http://translate.google.com/translate_tts?tl=hi&q=%26%232310%3B%26%232354%3B%26%232370%3B+%26%232327%3B%26%232379%3B%26%232349%3B%26%232368%3B", "/directory/loveme.mp3");如果我将两个URL都粘贴到浏览器中,它们都可以正常运行。但是第二个网址只复制了一个空白的mp3文件,而第一个网址复制了正确的MP3文件。
发布于 2011-03-25 08:24:39
在调用copy之前,尝试在URL上执行此操作。
function utf8RawUrlDecode ($source) {
$decodedStr = "";
$pos = 0;
$len = strlen ($source);
while ($pos < $len) {
$charAt = substr ($source, $pos, 1);
if ($charAt == '%') {
$pos++;
$charAt = substr ($source, $pos, 1);
if ($charAt == 'u') {
// we got a unicode character
$pos++;
$unicodeHexVal = substr ($source, $pos, 4);
$unicode = hexdec ($unicodeHexVal);
$entity = "&#". $unicode . ';';
$decodedStr .= utf8_encode ($entity);
$pos += 4;
}
else {
// we have an escaped ascii character
$hexVal = substr ($source, $pos, 2);
$decodedStr .= chr (hexdec ($hexVal));
$pos += 2;
}
} else {
$decodedStr .= $charAt;
$pos++;
}
}
return $decodedStr;
}这是我从docs for rawurldecode上的评论中得到的--向下滚动。
https://stackoverflow.com/questions/5427144
复制相似问题