Click here to Skip to main content
12,243,738 members (40,493 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: .NET3.0 C#3.0 C# .NET
I have a base 64 string like this:

H4sIAAAAAAAAAFWUUY6kMAxEz7Iqae9haM8QCAmTpBn1z97/GBs7kJgfXOV6AtpxQ444fPPPP7pFyPznNiA/bRK2opFK0F54o3eJkhqtyPCg8FoSTRT0NtYoaRqgw3mBWtFYJSgvcfP8kXBIBboFvVM8Fko7CWaNgqaBiVZaFxdeNbRaQOMx8S5vchVNVWJyydMc0xEktkYh08AU99eHnU7WagWHx8x5ru2rSNok5oVDOLgkme7DKGQakGdewzVSsW7xcqfLnqaaGCnQsPjmvLij9rsQ4DZYZnnJdpVAFZZY2DN7mbnVSgyPOlxHM+81MlKoYeHONHsXvpLc4WEUNA2sf7frpw4lUHfYOMdEezvlhxHONuBdkcO+isRNwr8PJyd8V42axk6Ld19cu0NJ3p0QmakuT27QMBfXG9hj5jQRJyGNVnB47HWfs9P7daXM7XCQDF3XzUhhhsXBwQVPOg2rFRseumSBi2JdNuq2OBKtbbBDKXI7HO+weh8/yhit1PBI0Rc57btKfmnk2dVOu0pfFfKSmNsuGal5t8iFU12cyckf6GEUNA3kT93Ga52sVnB4FCpU/4byMCOFGhbFFZKtuavGTaMU/b5cRROVKGfeY4ly+EYq0C1Ot9Ln/qY+jIC2gVPmJ2vShSKXwW+ct/7RfBjBbAP/AU+zD1M2BgAA

I want to convert this string to normal string

Please, can any one help me?

I have already used two methods:
1:
byte[] encodedDataAsBytes
                = System.Convert.FromBase64String(data);
            string returnValue =
               System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
            return returnValue;
2:
byte[] b = Convert.FromBase64String(data);
 string strOriginal = System.Text.Encoding.UTF8.GetString(b);
 return strOriginal;
but this methods not converting into normal format of string
Posted 28-Mar-11 20:22pm
Edited 28-Mar-11 20:24pm
JF201554.5K
v2
Comments
Amund Gjersøe 30-Mar-11 9:22am
   
Where did you get the string you want to convert, and are you really sure it is only base64-converted? Is the text written in arabic encoding?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

ASCII encoding and UTF decoding?!

Use following instead-
public string DecodeBase64String(string encodedData)
{
byte[] encodedDataAsBytes = System.Convert.FromBase64String(encodedData);
string returnValue = System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
return returnValue;
}
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 29 Mar 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100