0

Client side code (angularjs controller)

var p="gemüse8";

var pb= $base64.encode(p); // pb= Z2Vt/HNlOA==

from server side(C#)

string b64="Z2Vt/HNlOA==";

byte[] data = Convert.FromBase64String(b64);

string decodedString = Encoding.UTF8.GetString(data);

result showing "gem�se8"

How can i properly decode this string?

2
  • 4
    Whatever $base64.encode is seems to be using iso-8859-1 (or similar) rather than UTF - which probably needs addressing - as it stands use Encoding.GetEncoding("iso-8859-1").GetString(data) Commented Jul 7, 2017 at 10:39
  • @AlexK. that helps. Please post as answer Commented Jul 8, 2017 at 17:15

1 Answer 1

1

Whatever $base64.encode is seems to be using ISO-8859-1 (or similar) encoding rather than UTF - which probably needs addressing.

As it stands use:

string decodedString = Encoding.GetEncoding("iso-8859-1").GetString(data);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.