|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
conversion issueI have them in a byte() array. (variable rawbytes()) How do I convert them to a readable string? I have for example following values 0,208,65,11,96,147,0,6,91,184, ... I tried For i = 0 To Packethdr.Caplength - 1 ch = System.Convert.ToChar(Rawbytes(i)) str.Concat(ch.ToString) Next This return an empty string. Can anybody help me? Regards Geert LS wrote:
> I use winpcap in dotnet to capture packets from the wire. You can use the System.Text.Encoding.ASCII.GetString() method to convert a> I have them in a byte() array. (variable rawbytes()) > How do I convert them to a readable string? byte-array to a string, as follows: Dim b As Byte() = {65, 66, 67, 68, 69} Dim s As String s = System.Text.Encoding.ASCII.GetString(b) MsgBox(s) Hope that helps, -- (O) e n o n e "LS" <inva***@invalid.com> schrieb: Take a look at the 'System.Text.Encoding.<encoding name>.GetString' methods. >I use winpcap in dotnet to capture packets from the wire. > I have them in a byte() array. (variable rawbytes()) > How do I convert them to a readable string? Notice that 'String.Concat' is a /shared/ method which will /return/ the result of the concatenation. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Geert,
As the others suggest use the appropriate System.Text.Encoding object for the character encoding that you are receiving. | 0,208,65,11,96,147,0,6,91,184, ... Your string is not empty per se, however the Debugger will make it appear it | This return an empty string. | Can anybody help me? is, as your first & seventh characters are ChrW(0) which the debugger treats as a string terminator. In addition to the debugger a number of Win32 APIs that you may call via P/Invoke (Declare statements) will also treat ChrW(0) as a string terminator. System.String itself however treats ChrW(0) as any other valid character. Hope this helps Jay Show quoteHide quote "LS" <inva***@invalid.com> wrote in message news:OIV7JQ7OFHA.3380@TK2MSFTNGP15.phx.gbl... |I use winpcap in dotnet to capture packets from the wire. | I have them in a byte() array. (variable rawbytes()) | How do I convert them to a readable string? | | I have for example following values | 0,208,65,11,96,147,0,6,91,184, ... | | I tried | | For i = 0 To Packethdr.Caplength - 1 | ch = System.Convert.ToChar(Rawbytes(i)) | str.Concat(ch.ToString) | Next | | This return an empty string. | Can anybody help me? | | Regards | | Geert | |
How to access aspx page thru the menu control only?
Reading Output from Shell Command How to Move Mouse to Control with Focus Writing TIF to database Dataview Find method, case insensitive? Problems with the excel find function in vb.net open binary file and search hex string Remote debugging: Unable to map the debug start page URL to a machine name Moving a windows form from a windows app to a class library. XMLReader and VB.Net |
|||||||||||||||||||||||