J
Jeff Stewart
I wrote the following function to accomodate a legacy driver function
that only accepted VB6-style strings. The driver expects a string
that represents an array of binary data to be sent over USB.
Private Function byteArrayToString(ByVal byteArray() As Byte) As
String
Dim returnString As String = New String("")
Dim i As Integer
For i = 0 To byteArray.Length - 1
returnString += Chr(byteArray(i))
Next
Return returnString
End Function
I wrote this function because all of the functions I found in
System.Text.Encoding insisted on interpreting my byte array of binary
data as UTF8 or ASCII or Unicode or whatever, effectively returning a
string that differed from the byte array on a character-by-character
basis. Most often, bytes like 0xE6 would be converted to 0x06.
Isn't there a .NET function that will do what I did?
that only accepted VB6-style strings. The driver expects a string
that represents an array of binary data to be sent over USB.
Private Function byteArrayToString(ByVal byteArray() As Byte) As
String
Dim returnString As String = New String("")
Dim i As Integer
For i = 0 To byteArray.Length - 1
returnString += Chr(byteArray(i))
Next
Return returnString
End Function
I wrote this function because all of the functions I found in
System.Text.Encoding insisted on interpreting my byte array of binary
data as UTF8 or ASCII or Unicode or whatever, effectively returning a
string that differed from the byte array on a character-by-character
basis. Most often, bytes like 0xE6 would be converted to 0x06.
Isn't there a .NET function that will do what I did?