/**
- 实体字符编码
- @param {*} text 待编码的文本
- @returns
/
function entitiesEncode(text) {
text = text.replace(/&/g, "&");
text = text.replace(/</g, "<");
text = text.replace(/>/g, ">");
text = text.replace(/ /g, " ");
text = text.replace(/"/g, """);
return text;
}
/* - 实体字符解码
- @param {*} text 待解码的文本
- @returns
*/
function entitiesDecode(text) {
text = text.replace(/&/g, "&");
text = text.replace(/</g, "<");
text = text.replace(/>/g, ">");
text = text.replace(/ /g, " ");
text = text.replace(/"/g, "'");
return text;
}