; i = 0 out = "" While (i < len1) Do c1 = base64DecodeChars(Asc(Mid(str, i + 1, 1)) And 255) i = i + 1 Loop While (i < len1 And c1 = -1) If (c1 = -1) Then base64decode = out Exit Function End If Do c2 = base64DecodeChars(Asc(Mid(str, i + 1, 1)) And 255) i = i + 1 Loop While (i < len1 And c2 = -1) If (c2 = -1) Then base64decode = out Exit Function End If out = out + Chr((c1 * 4) Or ((c2 And 48) \ 16))
Do c3 = base64DecodeChars(Asc(Mid(str, i + 1, 1)) And 255) i = i + 1 If (c3 = 61) Then base64decode = out c3 = base64DecodeChars(c3) End If Loop While (i < len1 And c3 = -1) If (c3 = -1) Then base64decode = out Exit Function End If out = out + Chr(((c2 And 15) * 16) Or ((c3 And 60) \ 4))
Do c4 = base64DecodeChars(Asc(Mid(str, i + 1, 1)) And 255) i = i + 1 If (c4 = 61) Then base64decode = out c4 = base64DecodeChars(c4) End If Loop While (i < len1 And c4 = -1) If (c4 = -1) Then base64decode = out Exit Function End If
out = out + Chr(((c3 And 3) * 64) Or c4) Wend base64decode = out End Function
Function utf16to8(str As String) As String
Dim out, i, len1, c out = "" len1 = Len(str) For i = 1 To len1 c = Asc(Mid(str, i, 1)) If ((c >= 1) And (c <= 127)) Then out = out + Mid(str, i, 1) ElseIf (c > 2047) Then out = out + Chr(224 Or ((c \ 4096) And 15)) out = out + Chr(128 Or ((c \ 64) And 63)) out = out + Chr(128 Or (c And 63)) Else out = out + Chr(192 Or ((c \ 64) And 31)) out = out + Chr(128 Or (c And 63)) End If Next utf16to8 = out End Function
Function utf8to16(str As String) As String
Dim out, i, len1, c Dim char2, char3
out = "" len1 = Len(str) i = 0 While (i < len1) c = Asc(Mid(str, i + 1, 1)) i = i + 1 Select Case (c \ 16) Case 0 To 7 out = out + Mid(str, i, 1) Case 12, 13 char2 = Asc(Mid(str, i + 1, 1)) i = i + 1 out = out + Chr(((c And 31) * 64) Or (char2 And 31)) Case 14 char2 = Asc(Mid(str, i + 1, 1)) i = i + 1 char3 = Asc(Mid(str, i + 1, 1)) i = i + 1 out = out + Chr(((c And 15) * 4096) Or ((char2 And 63) * 64) Or ((char3 And 63))) End Select Wend
utf8to16 = out End Function
上一页 [1] [2] [3] [C语言系列]Socket 编程,一个服务器,多个客户端,互相通信 [常用软件]微软最新VoIP服务器及客户端软件下周开测 [常用软件]uTorrent:史上最省资源BT客户端试用 [常用软件]越看越流畅三款主流网络电视客户端导购 [常用软件]Allpeers:让Firefox摇身一变为P2P客户端 [常用软件]编译给自己专用的FTP客户端 [常用软件][网络]FTPRush FTP客户端 软件评测 [VB.NET程序]WinVista新技术 WCF开发指南之客户端开发 [VB.NET程序]建立同SAS交互的开发式VB客户端 [Web开发]利用JS获取IE客户端IP及MAC的实现
|