ASP字符串和十六进制互转函数
- Public Function HexToStr(ByVal StrHex)
- Dim Length
- Dim Max
- Dim Str
- Max = Len(StrHex)
- For Length = 1 To Max Step 2
- Str = Str & Chr("&h" & Mid(StrHex,Length,2))
- Next
- HexToStr = Str
- End Function
- Public Function StrToHex(ByVal Str)
- Dim Length
- Dim Max
- Dim StrHex
- Max = Len(Str)
- For Length = 1 To Max
- StrHex = StrHex & Right("0" & Hex(Asc(Mid(Str,Length,1))),2)
- Next
- StrToHex = StrHex
- End Function
复制代码 |