asp將全角的字符轉(zhuǎn)變成半角字符,將半角轉(zhuǎn)變成全角d的代碼
更新時(shí)間:2008年01月09日 13:37:31 作者:
asp將全角的字符轉(zhuǎn)變成半角字符,將半角轉(zhuǎn)變成全角d的代碼
將全角的字符轉(zhuǎn)變成半角字符,將半角轉(zhuǎn)變成全角
<%
Function DSConvert(vString,vFlag)
Rem vFlag為0時(shí)表示從全角轉(zhuǎn)為半角,為其他時(shí)表示從半角轉(zhuǎn)為全角
Dim i,tmpSingleCharaASC,TempResult,SAscString,DAscString
SAscString = "1,2,3,4,5,6,7,8,14,15,16,17,18,19,20,21,22,23,24,25,26,27,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126"
DAscString = "-23679,-23678,-23677,-23676,-23675,-23674,-23673,-23672,-23666,-23665,-23664,-23663,-23662,-23661,-23660,-23659,-23658,-23657,-23656,-23655,-23654,-23653,-23647,-23646,-23645,-23644,-23643,-23642,-23641,-23640,-23639,-23638,-23637,-23636,-23635,-23634,-23633,-23632,-23631,-23630,-23629,-23628,-23627,-23626,-23625,-23624,-23623,-23622,-23621,-23620,-23619,-23618,-23617,-23616,-23615,-23614,-23613,-23612,-23611,-23610,-23609,-23608,-23607,-23606,-23605,-23604,-23603,-23602,-23601,-23600,-23599,-23598,-23597,-23596,-23595,-23594,-23593,-23592,-23591,-23590,-23589,-23588,-23587,-23586,-23585,-23584,-23583,-23582,-23581,-23580,-23579,-23578,-23577,-23576,-23575,-23574,-23573,-23572,-23571,-23570,-23569,-23568,-23567,-23566,-23565,-23564,-23563,-23562,-23561,-23560,-23559,-23558,-23557,-23556,-23555,-23554"
TempResult = ""
If Len(vString) <= 0 Then Response.Write "Parameters Error! Please Check Your Parameters!" : Response.End : Exit Function
For i=1 to Len(vString)
tmpSingleCharaASC = Asc(Mid(vString,i,1))
If vFlag = 0 Then
If InStr(DAscString,tmpSingleCharaASC) <> 0 and len(Cstr(tmpSingleCharaASC)) = 6 Then
TempResult = TempResult & Chr(tmpSingleCharaASC+23680)
Else
TempResult = TempResult & Chr(tmpSingleCharaASC)
End If
Else
If InStr(SAscString,tmpSingleCharaASC) <> 0 and Len(Cstr(tmpSingleCharaASC))<=4 Then
TempResult = TempResult & Chr(tmpSingleCharaASC-23680)
Else
TempResult = TempResult & Chr(tmpSingleCharaASC)
End If
End If
Next
DSConvert = TempResult
End Function
%>
全角轉(zhuǎn)半角
<%= DSConvert("1234566465454",0)%>
半角轉(zhuǎn)全角
<%= DSConvert("1234567890132131",1)%>
<%
Function DSConvert(vString,vFlag)
Rem vFlag為0時(shí)表示從全角轉(zhuǎn)為半角,為其他時(shí)表示從半角轉(zhuǎn)為全角
Dim i,tmpSingleCharaASC,TempResult,SAscString,DAscString
SAscString = "1,2,3,4,5,6,7,8,14,15,16,17,18,19,20,21,22,23,24,25,26,27,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126"
DAscString = "-23679,-23678,-23677,-23676,-23675,-23674,-23673,-23672,-23666,-23665,-23664,-23663,-23662,-23661,-23660,-23659,-23658,-23657,-23656,-23655,-23654,-23653,-23647,-23646,-23645,-23644,-23643,-23642,-23641,-23640,-23639,-23638,-23637,-23636,-23635,-23634,-23633,-23632,-23631,-23630,-23629,-23628,-23627,-23626,-23625,-23624,-23623,-23622,-23621,-23620,-23619,-23618,-23617,-23616,-23615,-23614,-23613,-23612,-23611,-23610,-23609,-23608,-23607,-23606,-23605,-23604,-23603,-23602,-23601,-23600,-23599,-23598,-23597,-23596,-23595,-23594,-23593,-23592,-23591,-23590,-23589,-23588,-23587,-23586,-23585,-23584,-23583,-23582,-23581,-23580,-23579,-23578,-23577,-23576,-23575,-23574,-23573,-23572,-23571,-23570,-23569,-23568,-23567,-23566,-23565,-23564,-23563,-23562,-23561,-23560,-23559,-23558,-23557,-23556,-23555,-23554"
TempResult = ""
If Len(vString) <= 0 Then Response.Write "Parameters Error! Please Check Your Parameters!" : Response.End : Exit Function
For i=1 to Len(vString)
tmpSingleCharaASC = Asc(Mid(vString,i,1))
If vFlag = 0 Then
If InStr(DAscString,tmpSingleCharaASC) <> 0 and len(Cstr(tmpSingleCharaASC)) = 6 Then
TempResult = TempResult & Chr(tmpSingleCharaASC+23680)
Else
TempResult = TempResult & Chr(tmpSingleCharaASC)
End If
Else
If InStr(SAscString,tmpSingleCharaASC) <> 0 and Len(Cstr(tmpSingleCharaASC))<=4 Then
TempResult = TempResult & Chr(tmpSingleCharaASC-23680)
Else
TempResult = TempResult & Chr(tmpSingleCharaASC)
End If
End If
Next
DSConvert = TempResult
End Function
%>
全角轉(zhuǎn)半角
<%= DSConvert("1234566465454",0)%>
半角轉(zhuǎn)全角
<%= DSConvert("1234567890132131",1)%>
相關(guān)文章
多域名一網(wǎng)站時(shí)如果返回最原來(lái)的域名
[紅色]多域名一網(wǎng)站時(shí)如果返回最原來(lái)的域名...2006-12-12在asp中通過(guò)getrows實(shí)現(xiàn)數(shù)據(jù)庫(kù)記錄分頁(yè)的一段代碼
在asp中通過(guò)getrows實(shí)現(xiàn)數(shù)據(jù)庫(kù)記錄分頁(yè)的一段代碼...2006-11-11ASP中if語(yǔ)句、select 、while循環(huán)的使用方法
這篇文章主要介紹了ASP中if語(yǔ)句、select 、while循環(huán)的使用方法,需要的朋友可以參考下2015-11-11asp中使用redim、preserve創(chuàng)建動(dòng)態(tài)數(shù)組實(shí)例
這篇文章主要介紹了asp中使用redim、preserve創(chuàng)建動(dòng)態(tài)數(shù)組實(shí)例,本文還給出了ASP中其它的數(shù)組操作例子,需要的朋友可以參考下2014-08-08Asp Conn.execute的參數(shù)與返回值總結(jié)
這篇文章主要介紹了Asp Conn.execute的參數(shù)與返回值總結(jié),數(shù)據(jù)庫(kù)對(duì)象的execute方法參數(shù)與返回值總結(jié),需要的朋友可以參考下2014-07-07