ASP converts a full-width character into a half-width character and a full-width D code

Source: Internet
Author: User

Converts a fullwidth character into a halfwidth character and a fullwidth character.
<%
Function dsconvert (vstring, vflag)
When REM vflag is 0, it indicates converting from full-width to half-width. If it is other, it indicates converting from half-width to full-width.
Dim I, tmpsinglecharaasc, tempresult, sascstring, dascstring
Sascstring = ", 46, listen, 49,50, 51,52, 53,54, 55,56, 57,58, 59,60, 61,62, 63,64, 65,66, 67,68, clerk, 77,78, 79,80, 81,82, 83,84, 85,86, 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, 88"

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
next
dsconvert = tempresult
end function
%>
fullwidth to halfwidth
<% = dsconvert ("1234566465454 ", 0) %>
halfwidth to fullwidth
<% = dsconvert ("1234567890132131", 1) %>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.