Home of the Muppet Imperial Moderator Corps

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.
Permalink Send private email 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.
Permalink Send private email wicket awethome 
September 15th, 2006 8:07am
Can you post the exact exception?
Permalink Send private email 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.
Permalink Send private email 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
Permalink Send private email a2800276 
September 15th, 2006 9:44am
BTW, thanks for the invite and will be over so long as it doesn't expire or something before I get the time.
Permalink Send private email JoC 
September 15th, 2006 9:52am

This topic is archived. No further replies will be accepted.

Other topics: September, 2006 Other topics: September, 2006 Recent topics Recent topics