Click to See Complete Forum and Search --> : Converting Base64 encoded data


rushikeshl
November 1st, 2004, 06:41 PM
Hello,

I need to convert a Base64 encoded byte array to an ASCII string so that it can be displayed to the user. There are a whole lot of VB.NET functions to do that but none of them is converting the data successfully. All of them convert the data partly and return the other part as Base64 encoded. I think it might have to do something with the carriage return character embedded in the data. But, I am not quite sure on that. Does any one have a quick code for converting a byte array to an ASCII string ?

Thanks,
Rushi

Here's what I am using:

Dim arrByteErrors() As Byte

arrByteErrors = GetBase64Data()
Dim sData As String = System.Text.ASCIIEncoding.ASCII.GetString(arrByteErrors)
TextBox1.Text = sData

TheCPUWizard
November 1st, 2004, 08:17 PM
Looks correct at first clance.. what is the input and output data?

rushikeshl
November 1st, 2004, 11:55 PM
Hi CPUWizard,

The Base64 data is returned by a Web Service method written in Java. I am not sure how the Web Method is written since its not coded by our developers. They return an array of bytes. When I check the length of the array it is definitely more than the length of the string I get back from the GetString function. The length of the output data from the Web service in my case is 143 while the length of the converted string is 63 bytes. Hope this information helps to shed light regarding this behavior of Base64 data.

Thanks,
Rushi

TheCPUWizard
November 2nd, 2004, 06:57 AM
Base64 data IS typically longer! If you want help, please post the DATA that you believe is in error.