C# 将字符串转为ऩ这种的 html实体编码
1、字符串转为html实体编码
private string GetHtmlEntities(string str) { string r = string.Empty; for (int i = 0; i < str.Length; i++) { r += "&#" + Char.ConvertToUtf32(str, i) + ";"; } return r; }
JS版
function htmlentities(str) { var r = ""; for( i=0; i<str.length; i++ ) { temp = str.charCodeAt(i); r += "&#"+temp+";"; } // 也可以用一句正则表达式解决 // r = str.replace(/[\d\D]/g, function($0) { return "&#" + $0.charCodeAt(0) + ";"; }); return r; }