' Personal Code style note (the first lowercase alphabet in the variable name represents the variable type)
' I: an integer type;
' s: string;
Function U2utf8 (Byval a_inum)
Dim Sresult,sutf8
Dim Itemp,ihexnum,i
Ihexnum = Trim (a_inum)
If ihexnum = "" Then
Exit Function
End If
Sresult = ""
If (Ihexnum < 128) Then
Sresult = Sresult & Ihexnum
ElseIf (Ihexnum < 2048) Then
Sresult = ChrB (&h80 + (Ihexnum and &h3f))
Ihexnum = Ihexnum &h40
Sresult = ChrB (&hc0 + ihexnum and &h1f)) & Sresult
ElseIf (Ihexnum < 65536) Then
Sresult = ChrB (&h80 + (Ihexnum and &h3f))
Ihexnum = Ihexnum &h40
Sresult = ChrB (&h80 + ihexnum and &h3f)) & Sresult
Ihexnum = Ihexnum &h40
Sresult = ChrB (&he0 + ihexnum and &HF)) & Sresult
End If
U2utf8 = Sresult
End Function
Function Gb2utf (Byval a_sstr)
Dim sgb,sresult,stemp
Dim Ilen,iunicode,itemp,i
SGB = Trim (A_SSTR)
Ilen = Len (SGB)
For i = 1 to Ilen
Stemp = Mid (sgb,i,1)
itemp = ASC (stemp)
If (itemp>127 OR itemp<0) Then
Iunicode = AscW (stemp)
If iunicode<0 Then
Iunicode = Iunicode + 65536
End If
Else
Iunicode = itemp
End If
Sresult = Sresult & U2utf8 (Iunicode)
Next
Gb2utf = Sresult
End Function
' Invoke method
Response.BinaryWrite (Gb2utf ("Chinese"))