Home All Groups Group Topic Archive Search About

convert byte() in ASCII code to letters?

Author
14 May 2006 7:28 PM
Joris De Groote
Hi,

I have a 1 dimensional table byte with a number af characters in ASCII code.
How do I convert those ASCII codes to real letters?

Thanks

Author
14 May 2006 7:49 PM
Herfried K. Wagner [MVP]
"Joris De Groote" <joris.degro***@skynet.be> schrieb:
> I have a 1 dimensional table byte with a number af characters in ASCII
> code. How do I convert those ASCII codes to real letters?

'System.Text.ASCIIEncoding.GetString'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
14 May 2006 8:04 PM
Joris De Groote
That didn't work (VS2003 didn't know that), but I found this:
Encoding.ASCII.GetString(buffer)
However, the result is always empty (I checked the table and the values are
in the table)


Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:OKvy694dGHA.1436@TK2MSFTNGP05.phx.gbl...
> "Joris De Groote" <joris.degro***@skynet.be> schrieb:
>> I have a 1 dimensional table byte with a number af characters in ASCII
>> code. How do I convert those ASCII codes to real letters?
>
> 'System.Text.ASCIIEncoding.GetString'.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
15 May 2006 10:56 AM
AMercer
> That didn't work (VS2003 didn't know that), but I found this:
> Encoding.ASCII.GetString(buffer)
> However, the result is always empty (I checked the table and the values are
> in the table)

I think GetString stops on the first zero byte.  Is buffer(0) equal to zero?
Author
16 May 2006 7:12 AM
Joris De Groote
Hi,
it seems to stop at every 0
so I createdan if that changes 0's into spaces and now everything is OK.
Thanks!


Show quoteHide quote
"AMercer" <AMer***@discussions.microsoft.com> wrote in message
news:F4F6E436-AF40-45D7-BCB8-7C57470FDC21@microsoft.com...
>> That didn't work (VS2003 didn't know that), but I found this:
>> Encoding.ASCII.GetString(buffer)
>> However, the result is always empty (I checked the table and the values
>> are
>> in the table)
>
> I think GetString stops on the first zero byte.  Is buffer(0) equal to
> zero?
Author
15 May 2006 12:55 PM
spamsickle
Probably all you need to get VS2003 to know
'System.Text.ASCIIEncoding.GetString' is an 'Imports System' at the
beginning of your program.
Author
15 May 2006 11:40 AM
vbnetdev
Dim chars() As Char
        Dim bytes() As Byte = New Byte() {65, 83, 67, 73, 73, 32, 69, 110,
99, 111, 100, 105, 110, 103, 32, 69, 120, 97, 109, 112, 108, 101}
        Dim ascii As System.Text.ASCIIEncoding = New
System.Text.ASCIIEncoding()
        Dim charCount As Integer = ascii.GetCharCount(bytes, 6, 8)
        chars = New Char(charCount) {}
        Dim charsDecodedCount As Integer = ascii.GetChars(bytes, 6, 8,
chars, 0)
        MsgBox("{0} characters used to decode bytes.", charsDecodedCount)
        MsgBox("Decoded chars: ")
        Dim c As Char
        For Each c In chars
            MsgBox("[{0}]" & vbTab & c)
        Next

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



Show quoteHide quote
"Joris De Groote" <joris.degro***@skynet.be> wrote in message
news:%23iIvYy4dGHA.2456@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> I have a 1 dimensional table byte with a number af characters in ASCII
> code. How do I convert those ASCII codes to real letters?
>
> Thanks
>
Author
15 May 2006 12:17 PM
Cor Ligthert [MVP]
Joris,

Know that ASCII is (7 bits). In the Benelux is that in my opinion seldom
used.

Cor

Show quoteHide quote
"Joris De Groote" <joris.degro***@skynet.be> schreef in bericht
news:%23iIvYy4dGHA.2456@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> I have a 1 dimensional table byte with a number af characters in ASCII
> code. How do I convert those ASCII codes to real letters?
>
> Thanks
>