i获得与ie中相同的结果... 如果我使用innerHTML,createTextNode或allert,它没有什么不同...... 有什么建议吗? wojtek 你遇到什么样的问题? 我在IE中遇到的问题(对于linux ...),就是我得到一个正方形而不是 的角色。这是你得到的吗? ja于2006年12月2日在comp.lang.javascript中写道 : hi, i将实体转换成字符有问题,我正在使用函数: function entityToString(htmlString){ htmlString = htmlString.replace(/(&)(#)(\d {1,}}(;)/ g,function (tot,amp,cr,cp,sem){ 返回String.fromCharCode(cp); }) 返回(htmlString); } 这适用于所有浏览器(ff,opera,safari,konqueror)但是 不在ie :( 它似乎适用于所有欧洲和数学字符,但如果它得到一些 像这样& #477哪个是颠倒的e 如果我选择生成的文本(来自ff)并复制并粘贴到 记事本中我得到了结果与...相同... 如果我使用它没有任何不同innerHTML,createTextNode或者allert ... 这里的工作正常: alert(entityToString('''Hello world: ABCǝ'')) ================ 为什么不简化正则表达式和整个函数? 函数entityToString2(htmlString){ 返回htmlString.replace(/ \& \#(\d +) ; / g, 函数(y,x){return String.fromCharCode(x);}) } alert(entityToString2(''Hello world:ABCǝ'')) - Evertjan。 荷兰。 (请将我的电子邮件地址中的x'更改为点数) > 你遇到什么问题? 我在IE中遇到的问题(对于linux ...),是我得到的一个正方形而不是这个角色的。这是你得到的吗? 是的,这是它 hi, i have problems with converting entities to chars, i''m using function: function entityToString (htmlString){ htmlString = htmlString.replace(/(&)(#)(\d{1,})(;)/g, function(tot,amp,cr,cp,sem) {return String.fromCharCode(cp);}) return(htmlString); } and this works fine in all browsers (ff, opera, safari, konqueror) but notin ie :(it seems bo work with all european and math chars, but if it gets some likethis &#477 wich is upside down "e" also if i select generated text (from ff) and do copy and paste into notepadi get the same results as in ie... it makes no different if i use innerHTML, createTextNode or allert... any suggestion? wojtek 解决方案 On Dec 2, 11:24 am, "ja" <[email protected]:hi,i have problems with converting entities to chars, i''m using function:function entityToString (htmlString){ htmlString = htmlString.replace(/(&)(#)(\d{1,})(;)/g, function(tot,amp,cr,cp,sem) { return String.fromCharCode(cp); }) return(htmlString);}and this works fine in all browsers (ff, opera, safari, konqueror) but notin ie :(it seems bo work with all european and math chars, but if it gets some likethis &#477 wich is upside down "e"also if i select generated text (from ff) and do copy and paste into notepadi get the same results as in ie...it makes no different if i use innerHTML, createTextNode or allert...any suggestion?wojtekWhat sort of problem do you encounter?The problem I have in IE (for linux...), is that I get a square insteadof the character. Is it what you get? ja wrote on 02 dec 2006 in comp.lang.javascript: hi,i have problems with converting entities to chars, i''m using function:function entityToString (htmlString){ htmlString = htmlString.replace(/(&)(#)(\d{1,})(;)/g, function(tot,amp,cr,cp,sem) { return String.fromCharCode(cp);}) return(htmlString);}and this works fine in all browsers (ff, opera, safari, konqueror) butnot in ie :(it seems bo work with all european and math chars, but if it gets somelike this &#477 wich is upside down "e"also if i select generated text (from ff) and do copy and paste intonotepad i get the same results as in ie...it makes no different if i use innerHTML, createTextNode or allert... This works fine here: alert (entityToString(''Hello world: ABC ǝ'') ) ================ Why not simplify the regex and the whole function? function entityToString2 (htmlString){return htmlString.replace(/\&\#(\d+);/g,function(y,x) {return String.fromCharCode(x);})} alert (entityToString2(''Hello world: ABC ǝ'') ) --Evertjan.The Netherlands.(Please change the x''es to dots in my emailaddress)>What sort of problem do you encounter?The problem I have in IE (for linux...), is that I get a square insteadof the character. Is it what you get? yeah this is it 这篇关于数字实体到字符串和ie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-16 17:31