//unicodeÂë×ª»»³ÉGB2312
function URLDecode(enStr){ 
    var deStr,strSpecial   
    var c,i,v,q,p,t,s;
    deStr="";  
    strSpecial="!\"#$%&'()*+,.-_/:;<=>?@[\]^`{|}~%";  
    for(i=0;i<enStr.length;i++){  
        c=enStr.substr(i,1);    
        if (c=="%"){
            q=enStr.substr(i+1,2);
            v=eval("0x"+enStr.substr(i+1,2));
            p=String.fromCharCode(v);
            if(strSpecial.indexOf(p,0)!=-1){
                deStr=deStr+p;
                i=i+2;
            }
            else{
                q=enStr.substr(i+1,2);
                t=eval("0x"+q)-0xB0;
                q=enStr.substr(i+4,2);
                s=eval("0x"+q)-0xA1;
                if(t>=0 && s>=0){
                    v=t*94+s;
                    p=strGB.substr(v,1); 
                    //v=eval("0x"+enStr.substr(i+1,2)+enStr.substr(i+4,2));
                    //p=String.fromCharCode(v);
                    deStr=deStr+p;
                    i=i+5;
                }
                else{
                    v=eval("0x"+enStr.substr(i+1,2));
                    p=String.fromCharCode(v);
                    deStr=deStr+p;
                    i=i+2;
                }
            }
        }
        else{  
            if(c=="+"){  
                deStr=deStr+" ";
            }
            else{
                deStr=deStr+c;
            }   
        }   
    }  
    return deStr;   
}


//·¶Àý
//var str;
//str="%D6%D0%B9%FA%B3%CC%D0%F2%D4%B1%B4%F3%B1%BE%D3%AA+%3c%3e%22%23%25%7b%7d%7c%5e%7e%5b%5d%60%26%3f%2bAbc";   
//alert(URLDecode(str)); 




//utf8×ª³Éunicode±àÂë
function Utf8ToUnicode(strUtf8)
{
	var bstr = "";
	var nTotalChars = strUtf8.length;        // total chars to be processed.
	var nOffset = 0;                                        // processing point on strUtf8
	var nRemainingBytes = nTotalChars;        // how many bytes left to be converted
	var nOutputPosition = 0;
	var iCode, iCode1, iCode2;                        // the value of the unicode.

	while (nOffset < nTotalChars)
	{
			iCode = strUtf8.charCodeAt(nOffset);
			if ((iCode & 0x80) == 0)                        // 1 byte.
			{
					if ( nRemainingBytes < 1 )                // not enough data
							break;

					bstr += String.fromCharCode(iCode & 0x7F);
					nOffset ++;
					nRemainingBytes -= 1;
			}
			else if ((iCode & 0xE0) == 0xC0)        // 2 bytes
			{
					iCode1 =  strUtf8.charCodeAt(nOffset + 1);
					if ( nRemainingBytes < 2 ||                        // not enough data
							 (iCode1 & 0xC0) != 0x80 )                // invalid pattern
					{
							break;
					}

					bstr += String.fromCharCode(((iCode & 0x3F) << 6) | (         iCode1 & 0x3F));
					nOffset += 2;
					nRemainingBytes -= 2;
			}
			else if ((iCode & 0xF0) == 0xE0)        // 3 bytes
			{
					iCode1 =  strUtf8.charCodeAt(nOffset + 1);
					iCode2 =  strUtf8.charCodeAt(nOffset + 2);
					if ( nRemainingBytes < 3 ||                        // not enough data
							 (iCode1 & 0xC0) != 0x80 ||                // invalid pattern
							 (iCode2 & 0xC0) != 0x80 )
					{
							break;
					}

					bstr += String.fromCharCode(((iCode & 0x0F) << 12) |
									((iCode1 & 0x3F) <<  6) |
									(iCode2 & 0x3F));
					nOffset += 3;
					nRemainingBytes -= 3;
			}
			else                                                                // 4 or more bytes -- unsupported
					break;
	}

	if (nRemainingBytes != 0)
	{
			// bad UTF8 string.
			return "";
	}

	return bstr;
}

