Skip to content

ASCII码表代码+文本格式化处理代码

2008年1月7日

真的发现网页可以做很多事情,我现在已经用网页写了4个程序出来了。 先贴两个今天写完的。

ASCII码表:

html
<html>
<head><title>ASCII码表</title></head>
<body onload="asciitable()">
<script language="vbscript">
function asciitable()
    document.write "<table align='center' border='0'>"&chr(13)
    document.write "<tr><td colspan='20' align='center'>ASCII码表(VBScript自动生成)</td></tr>"&chr(13)
    j=0
    for i=1 to 127
        if j=0 then document.write "<tr>"
        document.write "<td>"&i&"</td><td>"&chr(i)&"</td>"
        j=j+1
        if j=10 then
            document.write "</tr>"&chr(13)
        j=0
        end if
    next
    document.write "</table>"
end function
</script>
</body>
</html>
<html>
<head><title>ASCII码表</title></head>
<body onload="asciitable()">
<script language="vbscript">
function asciitable()
    document.write "<table align='center' border='0'>"&chr(13)
    document.write "<tr><td colspan='20' align='center'>ASCII码表(VBScript自动生成)</td></tr>"&chr(13)
    j=0
    for i=1 to 127
        if j=0 then document.write "<tr>"
        document.write "<td>"&i&"</td><td>"&chr(i)&"</td>"
        j=j+1
        if j=10 then
            document.write "</tr>"&chr(13)
        j=0
        end if
    next
    document.write "</table>"
end function
</script>
</body>
</html>

文本格式化处理:

html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>文本格式化处理-抒寒开发</title></head>
<body>
<script language="vbscript">
function trans()
    text=text1.value
    text="    "&text
    text=replace(text,"`","'")
    text=replace(text,",",",")
    text=replace(text,".","。")
    text=replace(text,".","。")
    text=replace(text,"?","?")
    text=replace(text,"!","!")
    text=replace(text,":",":")
    text=replace(text,"(","(")
    text=replace(text,")",")")
    text=replace(text,"<<","《")
    text=replace(text,">>","》")
    text=replace(text,"。。。","…")
    text=replace(text,"…。","…")
    text=replace(text,"…。","…")
    text=replace(text,":"&chr(13),":  ")
    text=replace(text,"。"&chr(13),"。  ")
    text=replace(text,"?"&chr(13),"?  ")
    text=replace(text,"!"&chr(13),"!  ")
    text=replace(text,"…"&chr(13),"…  ")
    text=replace(text,chr(13),"")
    text=replace(text,chr(10),"")
    text=replace(text,"  "," ")
    text=replace(text,"  ","  ")
    text=replace(text,"    ","  ")
    text=replace(text,"   ","  ")
    text=replace(text,"   ","  ")
    text=replace(text,"  ",chr(13)&"  ")
    text=right(text,len(text)-1)
    text2.value=text
end function
</script>
<script language="javascript">
function copytext(obj,formname) {
    ie = (document.all)? true:false
    if (ie){
        var rng = document.body.createTextRange();
        rng.moveToElementText(obj);
        rng.scrollIntoView();
        rng.select();
        rng.execCommand("Copy");
        rng.collapse(false);
        alert("文本复制成功!")
    }
}
</script>
<div align="center" style="margin:auto;padding:2px;width:760px;border:1px dotted;font-size:12px;color:#5d78bf;">
    <div align="left" style="padding:8px; height:20px;background:#e4f1ff;">
        <div style="width:400px;float:left;font-size:16px;">文本格式化处理程序V1.0</div>
        <div style="width:50px;float:right"><a href="javascript:window.close()">关闭窗口</a></div>
    </div>
    <div align="left" style="padding:10px 20px;">请粘贴待处理文本并按“处理”:<input type="button" value="处理" onclick="trans()" /></div>
    <textarea rows="10" cols="100" name="text1" id="text1"></textarea>
    <div align="left" style="padding:10px 20px;">处理后的文本,可点击按钮复制:<input type="button" value="复制" onclick="copytext(text2)" /></div>
    <textarea rows="10" cols="100" name="text2" id="text2"></textarea>
    <div align="left" style="padding:20px;">
        说明:<br />
        1、本程序仅适合处理中文文章,英文文章、源代码等请勿用本程序处理。<br />
        2、本程序处理内容:英文标点换中文标点,段首空格、换行符、标点符号等标准化。<br />
        3、本程序尚处于测试阶段,可能存在功能不稳定的情况,处理前请务必备份好原文件。<br />
    </div>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>文本格式化处理-抒寒开发</title></head>
<body>
<script language="vbscript">
function trans()
    text=text1.value
    text="    "&text
    text=replace(text,"`","'")
    text=replace(text,",",",")
    text=replace(text,".","。")
    text=replace(text,".","。")
    text=replace(text,"?","?")
    text=replace(text,"!","!")
    text=replace(text,":",":")
    text=replace(text,"(","(")
    text=replace(text,")",")")
    text=replace(text,"<<","《")
    text=replace(text,">>","》")
    text=replace(text,"。。。","…")
    text=replace(text,"…。","…")
    text=replace(text,"…。","…")
    text=replace(text,":"&chr(13),":  ")
    text=replace(text,"。"&chr(13),"。  ")
    text=replace(text,"?"&chr(13),"?  ")
    text=replace(text,"!"&chr(13),"!  ")
    text=replace(text,"…"&chr(13),"…  ")
    text=replace(text,chr(13),"")
    text=replace(text,chr(10),"")
    text=replace(text,"  "," ")
    text=replace(text,"  ","  ")
    text=replace(text,"    ","  ")
    text=replace(text,"   ","  ")
    text=replace(text,"   ","  ")
    text=replace(text,"  ",chr(13)&"  ")
    text=right(text,len(text)-1)
    text2.value=text
end function
</script>
<script language="javascript">
function copytext(obj,formname) {
    ie = (document.all)? true:false
    if (ie){
        var rng = document.body.createTextRange();
        rng.moveToElementText(obj);
        rng.scrollIntoView();
        rng.select();
        rng.execCommand("Copy");
        rng.collapse(false);
        alert("文本复制成功!")
    }
}
</script>
<div align="center" style="margin:auto;padding:2px;width:760px;border:1px dotted;font-size:12px;color:#5d78bf;">
    <div align="left" style="padding:8px; height:20px;background:#e4f1ff;">
        <div style="width:400px;float:left;font-size:16px;">文本格式化处理程序V1.0</div>
        <div style="width:50px;float:right"><a href="javascript:window.close()">关闭窗口</a></div>
    </div>
    <div align="left" style="padding:10px 20px;">请粘贴待处理文本并按“处理”:<input type="button" value="处理" onclick="trans()" /></div>
    <textarea rows="10" cols="100" name="text1" id="text1"></textarea>
    <div align="left" style="padding:10px 20px;">处理后的文本,可点击按钮复制:<input type="button" value="复制" onclick="copytext(text2)" /></div>
    <textarea rows="10" cols="100" name="text2" id="text2"></textarea>
    <div align="left" style="padding:20px;">
        说明:<br />
        1、本程序仅适合处理中文文章,英文文章、源代码等请勿用本程序处理。<br />
        2、本程序处理内容:英文标点换中文标点,段首空格、换行符、标点符号等标准化。<br />
        3、本程序尚处于测试阶段,可能存在功能不稳定的情况,处理前请务必备份好原文件。<br />
    </div>
</div>
</body>
</html>