string to bytes的转化
2005-09-23 12:42
435 查看
'**********************************************************************************************
'** Procedure: KeyToBytes
'**
'** Description: Returns log file name including path based on config settings and date.
'**********************************************************************************************
Private Shared Function KeyToBytes(ByVal mstring As String) As Byte()
Dim mchararray As Char()
Dim result As Byte()
Dim mbytearray As Byte()
Dim i As Integer = 0
Dim t As Integer = 0
Dim m As Integer = 0
Dim bytelength As Integer
mchararray = mstring.ToCharArray()
bytelength = BitConverter.GetBytes(mchararray(0)).Length()
While (Not mchararray(m) = "")
result = BitConverter.GetBytes(mchararray(m))
For t = 0 To bytelength Step 1
mbytearray(i) = result(t)
i += 1
If i > 16 Then
Exit While
End If
Next
m += 1
End While
If i < 16 Then
While (i <= 16)
mbytearray(i) = 0
i += 1
End While
End If
Return mbytearray
End Function
'**********************************************************************************************
'** Procedure: MessageToBytes
'**
'** Description: Returns log file name including path based on config settings and date.
'**********************************************************************************************
Private Shared Function MessageToBytes(ByVal mstring As String) As Byte()
Dim mchararray As Char()
Dim result As Byte()
Dim mbytearray As Byte()
Dim i As Integer = 0
Dim t As Integer = 0
Dim m As Integer = 0
Dim bytelength As Integer
mchararray = mstring.ToCharArray()
bytelength = BitConverter.GetBytes(mchararray(0)).Length()
While (Not mchararray(m) = "")
result = BitConverter.GetBytes(mchararray(m))
For t = 0 To bytelength Step 1
mbytearray(i) = result(t)
i += 1
'If i > 16 Then
'Exit While
'End If
Next
m += 1
End While
'If i < 16 Then
'While (i <= 16)
'mbytearray(i) = 0
'i += 1
'End While
'End If
Return mbytearray
End Function
'** Procedure: KeyToBytes
'**
'** Description: Returns log file name including path based on config settings and date.
'**********************************************************************************************
Private Shared Function KeyToBytes(ByVal mstring As String) As Byte()
Dim mchararray As Char()
Dim result As Byte()
Dim mbytearray As Byte()
Dim i As Integer = 0
Dim t As Integer = 0
Dim m As Integer = 0
Dim bytelength As Integer
mchararray = mstring.ToCharArray()
bytelength = BitConverter.GetBytes(mchararray(0)).Length()
While (Not mchararray(m) = "")
result = BitConverter.GetBytes(mchararray(m))
For t = 0 To bytelength Step 1
mbytearray(i) = result(t)
i += 1
If i > 16 Then
Exit While
End If
Next
m += 1
End While
If i < 16 Then
While (i <= 16)
mbytearray(i) = 0
i += 1
End While
End If
Return mbytearray
End Function
'**********************************************************************************************
'** Procedure: MessageToBytes
'**
'** Description: Returns log file name including path based on config settings and date.
'**********************************************************************************************
Private Shared Function MessageToBytes(ByVal mstring As String) As Byte()
Dim mchararray As Char()
Dim result As Byte()
Dim mbytearray As Byte()
Dim i As Integer = 0
Dim t As Integer = 0
Dim m As Integer = 0
Dim bytelength As Integer
mchararray = mstring.ToCharArray()
bytelength = BitConverter.GetBytes(mchararray(0)).Length()
While (Not mchararray(m) = "")
result = BitConverter.GetBytes(mchararray(m))
For t = 0 To bytelength Step 1
mbytearray(i) = result(t)
i += 1
'If i > 16 Then
'Exit While
'End If
Next
m += 1
End While
'If i < 16 Then
'While (i <= 16)
'mbytearray(i) = 0
'i += 1
'End While
'End If
Return mbytearray
End Function
相关文章推荐
- python 将二进制字符串转化为字符串 Convert bytes to a Python string
- Android convertToBytes StringIndexOutOfBoundsException 调试小结
- Bytes to float int String Double
- String field contains invalid UTF-8 data when serializing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes.
- String to Integer (atoi) 将字符串转化成整数
- Python 3 : Convert string to bytes
- leetcode:String to Integer (atoi) 字符串转化成整数
- spark厦大---标签和索引的转化:StringIndexer- IndexToString-VectorIndexer
- java.lang.Integer cannot be cast to java.lang.String Java int,double向String的转化和String向int,double的转换
- QT中 QString转化为String时候的toStdString与toLocal8Bit 的区别
- Dom to String(将xml文件转化为String)
- bytesToString
- Java把对象转化成流再转化成String,使用BASE64库加解密bytes
- Java bytesToHexString 解析
- Convert integer to string(int类型转化为string类型)
- ios convert nsdictionary to xml string 将字典转化为xml字符串
- scala--标签和索引的转化:StringIndexer- IndexToString-VectorIndexer
- java类型转化之Hbase ImmutableBytesWritable类型转String
- 把整型数组转化为相应的字符型数组Convert.ToString
- javascript string to bytes