var dtable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encodeBase64(src)
{
    var dest = "";
    var igroup1, igroup2, igroup3;
    var ogroup1, ogroup2, ogroup3, ogroup4;
    var count = 0;
    var i = 0;
    
    igroup1 = "";
    igroup2 = "";
    igroup3 = "";
    
    ogroup1 = "";
    ogroup2 = "";
    ogroup3 = "";
    ogroup4 = "";

    while (count < src.length)
    {
        i = 0;
        if (count < src.length)
        {
            i++;
            igroup1 = src.charCodeAt(count++);
        }
        if (count < src.length)
        {
            i++;
            igroup2 = src.charCodeAt(count++);
        }
        if (count < src.length)
        {
            i++;
            igroup3 = src.charCodeAt(count++);
        }
        ogroup1 = igroup1 >> 2;
        ogroup2 = ((igroup1 & 3) << 4) | (igroup2 >> 4);
        ogroup3 = ((igroup2 & 15) << 2) | (igroup3 >> 6);
        ogroup4 = igroup3 & 63;

 		if (i < 3)
		{
			ogroup4 = 64;
			if (i < 2)
			{
				ogroup3 = 64;
            }
		}
        
        dest = dest + dtable.charAt(ogroup1) + 
            dtable.charAt(ogroup2) + 
            dtable.charAt(ogroup3) + 
            dtable.charAt(ogroup4);
        igroup1 = "";
        igroup2 = "";
        igroup3 = "";
        
        ogroup1 = "";
        ogroup2 = "";
        ogroup3 = "";
        ogroup4 = "";
    }
    return dest;
}

// »¹Ô­url
function Preprocess(str)
{
	str = str.replace(/&lt/g,"<");
	str = str.replace(/&gt/g,">");
	str = str.replace(/&amp/g,"&");
	str = str.replace(/&quot/g,"\"");
	str = str.replace(/&apos/g,"\'");
	str = str.replace(/<br>/g,"\n");
	return str;
}

function SchemeEncode(str, isU2A)
{
	if (isU2A)
  {
  	return "qqdl://" + encodeBase64(strUnicode2Ansi(str));
  }
  else
  {
  	 return "qqdl://" + encodeBase64(str);
  }
}
