/**
- 實體字符編碼
- @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;
}