The method of generating Chinese characters randomly by ASP
<%dim I
Dim J
Dim HS
Dim He
Dim LS
Dim LE
Dim result
Result= ""
HS = 177
he = 247
LS = 161
LE = 254
Dim max_num
max_num=65536
Randomize
For i = 1 to 4
Temp1=dec2bin (Int (HE-HS) * RND ()) + HS)
Temp2=dec2bin (Int ((le-ls) * RND ()) + LS)
result = result & Chr (Binarytodecimal (Temp1 & Temp2)-Max_num)
Next
Response.Write Result & ""
%>
<%
"Here is the function
''-------------------------------------------
Public Function Dec2bin (mynum) ' Decimal to binary '
Dim Loopcounter
If mynum >= 2 ^ Then
Dec2bin = "Too Big"
Exit Function
End If
Todo
If (Mynum and 2 ^ loopcounter) = 2 ^ Loopcounter Then
Dec2bin = "1" & Dec2bin
Else
Dec2bin = "0" & Dec2bin
End If
Loopcounter = Loopcounter + 1
Loop Until 2 ^ loopcounter > Mynum
End Function
''-------------------------------------------
Public Function binarytodecimal (binaryvalue) ' Binary to decimal ' conversion
' Returns the decimal equivalent of a binary number
Dim IDX
Dim tmp
Dim result
Dim digits
digits = Len (binaryvalue)
For idx = digits to 1 Step-1
TMP = Mid (Binaryvalue, IDX, 1)
If tmp = "1" Then result = result + 2 ^ (DIGITS-IDX)
Next
Binarytodecimal = result
End Function
%>