|
-
May 13th, 2004, 10:05 AM
#1
Thread Starter
Lively Member
Convert.ToChar issue...
I need to convert an array of bytes to a string, but without using Unicode. Just ASCII (base 10 maybe).. so how can I do this? Here's my code, but this spits out a string of unicode characters representing the array, instead of the raw ASCII characters I need.
VB Code:
Public Shared Function ConvertHashToAscii(ByVal hash() As Byte) As String
Dim sb As New StringBuilder
Dim number As Byte
For Each number In hash
sb.Append(Convert.ToChar(number))
Next
Return sb.ToString
End Function
Any help, as always, is greatly appreciated.
Thanks,
KT
-
May 13th, 2004, 03:57 PM
#2
Hi.
Try this instead :
VB Code:
Public Shared Function ConvertHashToAscii(ByVal hash() As Byte) As String
Dim sb As New StringBuilder
Dim number As Byte
For Each number In hash
sb.Append(Chr(number)) 'Chr should use ASCii and NOT unicode.
Next
Return sb.ToString
End Function
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
May 13th, 2004, 05:06 PM
#3
I wonder how many charact
VB Code:
Public Shared Function ConvertHashToAscii(ByVal hash() As Byte) As String
Return New System.Text.ASCIIEncoding().GetString(hash)
End Function
Last edited by nemaroller; May 13th, 2004 at 05:11 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|