ASP Full-angle half-angle conversion function
Flag=-1, half angle to full angle
Flag=0 with half angle and full angle
Full angle and half angle when flag=1
Copy Code code as follows:
<%
Function DBC2SBC (STR, flag)
Dim I, SSTR
If Len (STR) <= 0 Then Exit Function
DBC2SBC = ""
For i = 1 to Len (STR)
SSTR = ASC (Mid (STR, I, 1))
Select Case Flag
Case-1
If sstr>0 and sstr<= Then
DBC2SBC = DBC2SBC & Chr (ASC (Mid (STR, I, 1))-23680
Else
DBC2SBC = DBC2SBC & Mid (STR, I, 1)
End If
Case 0
If sstr>0 and sstr<= Then
DBC2SBC = DBC2SBC & Chr (ASC (Mid (STR, I, 1))-23680
Else
DBC2SBC = DBC2SBC & Chr (ASC (Mid (STR, I, 1)) + 23680)
End If
Case 1
If sstr<0 Or sstr>125 Then
DBC2SBC = DBC2SBC & Chr (ASC (Mid (STR, I, 1)) + 23680)
Else
DBC2SBC = DBC2SBC & Mid (STR, I, 1)
End If
End Select
Next
End Function
%>
JavaScript version full-angle half-angle conversion function
Copy Code code as follows:
function DBC2SBC (SSTR) {
var DBC2SBC = sStr;
for (var i = 65281 i < 65375; i++) {
var re = new RegExp (String.fromCharCode (i), "G");
var va = string.fromcharcode (i-65248);
DBC2SBC = Dbc2sbc.replace (RE, VA);
}
DBC2SBC = dbc2sbc.replace (//g, ');
return DBC2SBC;
}
JavaScript Common functions Sbc2dbc ()
Copy Code code as follows:
function Sbc2dbc (sStr) {
var sbc2dbc = sStr;
for (var i = < 127; i++) {
Stringfromcharcode = String.fromCharCode (i);
Switch (stringfromcharcode) {
case (':
Case ') ':
Case ' * ':
case ' + ':
Case '/':
CA Se "\":
Case [":
Case"] ":
Case" ":
Case" $ ":
Case". ":
Case" ^ ":
Case" | ":
Stringfromcharcode = ' \ \ ' + Stringfromcharcode;
Default:
break;
}
var re = new RegExp (Stringfromcharcode, "G");
var va = string.fromcharcode (i + 65248);
Sbc2dbc = sbc2dbc.replace (RE, VA);
}
Sbc2dbc = Sbc2dbc.replace (//g, ');
return SBC2DBC;
}