惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
L
LINUX DO - 热门话题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
V
V2EX
GbyAI
GbyAI
量子位
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
B
Blog
Microsoft Security Blog
Microsoft Security Blog
S
SegmentFault 最新的问题
O
OpenAI News
N
News and Events Feed by Topic
博客园 - Franky
爱范儿
爱范儿
Forbes - Security
Forbes - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V2EX - 技术
V2EX - 技术
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Schneier on Security
Schneier on Security
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
人人都是产品经理
人人都是产品经理
P
Privacy International News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
Last Week in AI
Last Week in AI
罗磊的独立博客
Spread Privacy
Spread Privacy
Recent Announcements
Recent Announcements
The Cloudflare Blog
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
The Register - Security
The Register - Security
Y
Y Combinator Blog
J
Java Code Geeks
I
Intezer

博客园 - fengzhimei

The template you have chosen is invalid or cannot be found. CSS trick : text-transform Site Definition KickStart Project Transform between Hex and Dec in Javascript - fengzhimei Visual Studio 2005 Web Application Projects Template Overcome limitation of activate ActiveX control in IE "Suggested Web Parts" in SharePoint 2007 Web Part picker page. - fengzhimei Extend toolbar of HtmlEditor in SharePoint 2007 Expand querystring in URL with JavaScript Create a AJAX enabled WebPart for SharePoint2007 by using ASP.NET 2.0 client callback feature Code view is missing in SharePoint Designer Beta 2 when you try to edit a WSS v3 site. MOSS2007(Beta) SDK is online. .Net Framework v2.0 built-in tools StringBuilder in Javascript Remove duplicate rows from a table Remove duplicate items from collection Programatically download file from document library. Reset VSS Admin Password A nice piece of javascript to simulate Adodb Recordset.
Html entity encoder/decoder
fengzhimei · 2005-11-25 · via 博客园 - fengzhimei

Detail refer to

http://andrewu.co.uk/clj/entityencode/.

function TextToEntities(strPlainText, blnPartialEncodeOnly) {
    
var strPartial  = [];
    
var strFull     = [];
    
var intP        = 0;
    
var intF        = 0;
    
var objPartialRegExp = (new RegExp).compile("[\\w\\s]");

    
for (var intI=0; intI<strPlainText.length; ++intI) {
        
var strChar = strPlainText.charAt(intI);
        
var intChar = strChar.charCodeAt(0);

        
if (isNaN(intChar)) {
            
// IF CHAR FAILED TO DECODE, LEAVE AS CHAR
            strPartial.push(strFull.push(strChar));
        }

        
else {
            
var strEntity = "&#" + intChar + ";";
            strFull.push(strEntity);
            
// IF CHAR WAS [a-zA-Z0-9_ \t] LEAVE AS CHAR, ELSE REPLACE WITH ENTITY
            strPartial.push(objPartialRegExp.test(strChar) ? strChar : strEntity);
        }

    }

    
return (blnPartialEncodeOnly ? strPartial.join("") : strFull.join(""));
}


function EntitiesToText(strEncodedText) {
    
var strData     = String(strEncodedText);
    
var objRegExp   = (new RegExp).compile("&#(\\d+);""ig");

    
/* FOR EACH MATCH TO ANY ENTITY, REPLACE THAT
    ENTITY GLOBALLY WITH ITS SINGLE CHAR EQUIVALENT 
*/

    
while(strData.match(objRegExp)) {
        
var strCharMatch    = RegExp.$1;
        
var objRegExpMatch  = new RegExp("&#" + strCharMatch + ";""ig");
        strData 
= strData.replace(objRegExpMatch, String.fromCharCode(strCharMatch));
    }

    
return strData;
}