#If Win64 And VBA7 Then
privatedeclareptrsafefunctionmultibytetowidecharlib ' kernel32 ' (byvalcodepageaslong,ByVal dwFlags As Long, byvallpmultibyteter byval CCH multibyte As Long,ByVal lpWideCharStr As jddsmt,ByVal cchWideChar As Long ) as long
privatedeclareptrsafefunctionwidechartomultibytelib ' kernel32 ' (byvalcodepageaslong,ByVal dwFlags As Long,byvallpwidecharsecharstib ByVal lpMultiByteStrPtr As jddsmt,ByVal cchMultiByte As Long,ByVal lpDefaultChar As jddsmt,byvallpuseddedeeng
#Else
privatedeclarefunctionmultibytetowidecharlib ' kernel32 ' (byvalcodepageaslong,ByVal dwFlags As Long, byval lpmultibytestr As Long byval CCH multibyte as long,ByVal lpWideCharStr As Long,ByVal cchWideChar As Long ) as long
privatedeclarefunctionwidechartomultibytelib ' kernel32 ' (byvalcodepageaslong,ByVal dwFlags As Long, byval lpwidecharstr as long byval CCH widechar as long,ByVal lpMultiByteStr As Long,ByVal cchMultiByte As Long,ByVal lpDefaultChar As Long
#End If
privateconstcp _ ACP=0' defaulttoansicodepage
Private Const CP帅气背包=65001 ' default to utf-8代码页
'字符GD dcb/ppublicfunctionencodetobytes (byvalsdataasstring ) As Byte ) ) note:len ) sdata ) 0
dimaretn(asbyte
Dim nSize As Long
If nSize=0 Then Exit Function
WideCharToMultiByte CP帅气背包,0,strptr,-1,varptr,aretn,nSize,0,0
Erase aRetn
结束函数
' UTF8旋转字符
publicfunctiondecodetobytes (byvalsdataasstring ) As Byte ) ) ' note:len ) sdata ) 0
dimaretn(asbyte
Dim nSize As Long
If nSize=0 Then Exit Function
MultiByteToWideChar CP帅气背包,0,strptr,-1,varptr,aretn,nSize
Erase aRetn
结束函数
Sub CommandButton1_Click (
Dim s As String
s=strconv(encodetobytes (中文),vbUnicode ) '将以utf编码的数组转换为VB可处理的字符
t=decodetobytes(strconv(s,vbFromUnicode ) )
结结巴巴的懒汉/p