Chrome 及同内核的浏览器会将 URL 编码为 UTF-8,而 MSIE 默认不会,因此需要先判断当前请求的编码方式。

int count = 0;
                
                for (int i = 0; i < referer_orign.size(); i++)
                {
                
                	if (referer_orign[i] == '%')
                	{
                		++count;
                	}
                	if (count >= 3)
                	{
                		//if (referer_orign.find("MSIE") == string::npos || referer_orign.find("msie") == string::npos)
                		params = Utils::decodeURL(params);//decode for utf-8
                		break;
                	}
                }

基本思路是把 UTF-8 转换为 UTF-16(Unicode),再转换为 ASCII。

网页脚本 login.lua:


                local t={};
                
                function t:doRequest(p)
                
                	local name = p["name"];
                
                	if name=="我" then
                		return   "用户:"..name .." 登陆 成功 "   ;
                	end
                	return   "用户:"..name .." 登陆 失败 "   ;
                end
                
                return t;