func StrToUint16(Texts string)[]uint16{
Tmp:=[]uint16{}
Text:=[]byte{}
if len([]byte(Texts))%2==1{
Text = append([]byte(Texts),0x0)
}else{
Text = []byte(Texts)
}
for i:=0;i<=len(Text)-1;i+=2{
Ls:=binary.BigEndian.Uint16([]byte{Text[i],Text[i+1]})
Tmp = append(Tmp,Ls)
}
return Tmp
}
import (
“encoding/binary”
)
版权声明:本文为m0_59939822原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。