PHP-php如何将包含汉字的URL转为字母或数字
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/09 08:27:08
PHP-php如何将包含汉字的URL转为字母或数字
function redirectLink(url, link) {
var _url = base64decode(url);
link.setAttribute('href', _url);
return false;
}
function modifyLink(url){
url = base64decode(url);
window.location.href=url;
return false;
}
function base64decode(str) {
var c1, c2, c3, c4;
var i, len, out;
len = str.length;
i = 0;
out = "";
while(i < len) {
/* c1 */
do {
c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
} while(i < len && c1 == -1);
if(c1 == -1)
break;
/* c2 */
do {
c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
} while(i < len && c2 == -1);
if(c2 == -1)
break;
out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
/* c3 */
do {
c3 = str.charCodeAt(i++) & 0xff;
if(c3 == 61)
return out;
c3 = base64DecodeChars[c3];
} while(i < len && c3 == -1);
if(c3 == -1)
break;
out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
/* c4 */
do {
c4 = str.charCodeAt(i++) & 0xff;
if(c4 == 61)
return out;
c4 = base64DecodeChars[c4];
} while(i < len && c4 == -1);
if(c4 == -1)
break;
out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
}
return out;
var _url = base64decode(url);
link.setAttribute('href', _url);
return false;
}
function modifyLink(url){
url = base64decode(url);
window.location.href=url;
return false;
}
function base64decode(str) {
var c1, c2, c3, c4;
var i, len, out;
len = str.length;
i = 0;
out = "";
while(i < len) {
/* c1 */
do {
c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
} while(i < len && c1 == -1);
if(c1 == -1)
break;
/* c2 */
do {
c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
} while(i < len && c2 == -1);
if(c2 == -1)
break;
out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
/* c3 */
do {
c3 = str.charCodeAt(i++) & 0xff;
if(c3 == 61)
return out;
c3 = base64DecodeChars[c3];
} while(i < len && c3 == -1);
if(c3 == -1)
break;
out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
/* c4 */
do {
c4 = str.charCodeAt(i++) & 0xff;
if(c4 == 61)
return out;
c4 = base64DecodeChars[c4];
} while(i < len && c4 == -1);
if(c4 == -1)
break;
out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
}
return out;
PHP-php如何将包含汉字的URL转为字母或数字
PHP中如何比较位数很长的两个数字是否相等
求解释 90)PHP的BASE64编码中包含以下哪些? -------------------ABC A) 0-9的数字
php的+=是什么意思
用PHP 计算出文章中各个字母出现的次数
php5.4如何设置?有两个文件php.ini-development和php.ini-production,该将哪个文
php如何实现两个数相除php代码
php程序下如何计算100以内的偶数和
用php可不可以把汉字转换成字母数字形式?可是全是字母,可以全是数字,也可以全是字母加数字,但是不能有其它符号...
PHP中,如何将123456789 拆分成独立的1 2 3 4 5...和12 34 56 78 90
PHP::是什么意思
PHP中