base64 to unicode
Is there a way to convert a base64 string to a unicode string? I am trying this, but I get an exception saying there was a bad character in the base-64, in the third line. Clearly it means that the byte stream did not have base64 encoding in the first place. Or, it probably did, because the second line executed without reporting an exception.
byte[] bOutput = ..../*something, assuming that it gets a base-64 encoded stream*/
s = Convert.ToBase64String(bOutput);
s = new ASCIIEncoding().GetString(new ASCIIEncoding().GetBytes(s));
I just need to decode a base64 to a Unicode string.
jingalala jingalala ™
September 15th, 2006 8:06am
Maybe you shouldn't be using that ASCII object then? Maybe there's a unicode alternative? I dunno. .NET/C/C++ aren't really my bag.
Can you post the exact exception?
Senthilnathan N.S.
September 15th, 2006 8:14am
Here's the exception.
"Invalid character in a Base-64 string."
? ex.ToString()
"System.FormatException: Invalid character in a Base-64 string.
Sorry, I wrote the wrong line of code in the previous post. I have been hurrying myself into this and there's so much code I am trying and then wiping off and then re-writing, so I made the mistake of writing the wrong code.
I am not running the code in the OP. I am running this when I get the exception. I got it in another line.
I'll come back. Dang! I am going berserk. I'll come back later.
jingalala jingalala ™
September 15th, 2006 8:24am
byte[] bOutput = ..../*something, assuming that it gets a base-64 encoded stream*/
s = Convert.ToBase64String(bOutput);
this doesn't really make sense, your converting something which is already base64 to base64...
(by the way, I assume you've been invited to vanilla and just haven't showed up yet, or did we forget you?)
-tim
BTW, thanks for the invite and will be over so long as it doesn't expire or something before I get the time.
JoC
September 15th, 2006 9:52am