Click here to Skip to main content
15,923,083 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
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
Updated 28-Mar-11 19:24pm
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

ASCII encoding and UTF decoding?!

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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900