if (value.length > 30) {
var EncodeStr = EncodeString(value);
dsg = "<div title=\"" + EncodeStr + "\" >" + EncodeStr.substr(0, 30) + "...</div>";
}
else {
dsg = value;
}
//把特殊字符替换掉
function EncodeString(theString) {
theString = theString.replace(/>/g, ">");
theString = theString.replace(/</g, "<");
theString = theString.replace(/\[/g, "&【;");
theString = theString.replace(/]/g, "&】;");
theString = theString.replace(/{/g, "&ldk;");//左大括号
theString = theString.replace(/}/g, "&rdk;");//右大括号
theString = theString.replace(/\\"/g, """);//双引号
theString = theString.replace(/\\'/g, "#39;");//单引号
theString = theString.replace(/\\/g, "\\\\");//对斜线的转义
theString = theString.replace(/\n/g, "\\n");//回车键
theString = theString.replace(/\r/g, "\\r");
theString = theString.replace(/\\",/g, "#42;");//双引号,
theString = theString.replace(/&#/g, "#77;");//双引号,
return theString;
}
//把特殊字符替换回来
function DecodeString(theString) {
theString = theString.replace(/>/g, ">");
theString = theString.replace(/</g, "<");
theString = theString.replace(/&【;/g, "[");
theString = theString.replace(/&】;/g, "]");
theString = theString.replace(/&ldk;/g, "{");//左大括号
theString = theString.replace(/&rdk;/g, "}");//右大括号
theString = theString.replace(/"/g, "\"");
theString = theString.replace(/#39;/g, "\'");
theString = theString.replace(/\\\\/g, "\\");//对斜线的转义
theString = theString.replace(/\\n/g, "\n");//回车键
theString = theString.replace(/\\r/g, "\r/");
theString = theString.replace(/#42;/g, "\",");
theString = theString.replace(/#77;/g, "&#");//双引号,
return theString;
}