We all know that when we enter text and punctuation, we have full and half -horn to switch, so how to change in ASP programming? This article ASP instance tutorial, teach you to change between the full -angle half -angle.
JavaScript conversion part:
<script>
/*
*************************************
* Constitution of the site of the construction of the site:
* STR: String to be converted
* FLAG: Mark, turn to full at 0:30, and turn to half of it for Africa
* Return value type: string
*************************************
*/
Function DBC2SBC (Str, Flag) {{
var I;
var result = '';
if (str.Length <= 0) {alert ('String parameter error'); Return false;}
for (i = 0; I <str.length; i ++)
{str1 = str.charcodeat (i);
if (STR1 <125 &&! Flag)
Result+= string.fromcharcode (str.charcodeat (i) +65248);
else
Result+= string.fromcharcode (str.charcodeat (i) -65248);
}
Return result;
}
</script>
// Example:
<script>
alert (dbc2sbc (aAABC, 0));
document.write (DBC2SBC (ABCDEFG, 0))
</script>
ASP conversion part:
<%
'*******************************
'* Jianjian site learning parameter description:
'* Str: String to be converted
'* FLAG: Mark, turn over at 0:30, and turn to half of it for non -0 o'clock
'* Return value type: string
'*******************************
Function DBC2SBC (Str, FLAG)
dim I
if len (str) <= 0 then
msgbox 'string parameter error'
exit function
end if
for i = 1 to len (STR)
str1 = ASC (MID (STR, I, 1)))
if Str1> 0 and Str1 <= 125 and not flag then
DBC2SBC = DBC2SBC & CHR (ASC (MID (STR, I, 1)) -23680)
else
DBC2SBC = DBC2SBC & CHR (ASC (MID (STR, I, 1))+23680)
end if
next
end function
%>