2

I received this ISO-8859-1 data from Azure Function and I want to decode this to string but can't figure out how to achieve it.

Here is the Azure Function response data:

"x\u009c\u00ed=Yw\u00db\u00b8\u00ce\u00bf\u00a6\u00e7\u00dc\u00ef\u00a1>\u00da%?&m2\u009d\u00a5\u009d\u00dev\u00a6\u00d3\u00ce\u008b\u008f\u00ac\u00c5VcK\u00be\u00b2\u009c\u00c4\u00f9\u00f5\u009fv\u0011$(\u00d3\u00f1\u00a66L\u00db\u00d8\u0015\u0001\u0012\u0004@\u0010\u0084H\u00e2\u0095}\u00fdJ\u00d3V\u00dbW\u00dam2\u00fd\u001exY\u00fe\u00bfW\u00fa\u00d5+M\u00c9\u00bf\u00bc\u00ff\u00e5\u00e3\u00e4\u00de\u0018\u00e5\u001f\u00c5S\u00edM\u00f5t\u001eD-\u00906r\" So on and so forth.
        

The expected decoded string should be like this

{"data":[{"color":"rgb(160,160,164)","flatshading":false,"hoverinfo":"skip","type":"mesh3d","x":[0,21.3088,9.198,3.2605,-15.5898],"y":[0,-18.1459,-30.0058,-30.3949,-15.5255],"z":[-0.002,-0.002,-0.002,-0.002,-0.002]},{"color":"rgba(149, 165, 166, 1)" .. So on and so forth

I tried to do with this implementation but not working well. the decodedString is different from the expected result.

              var isoBytes = azureFunctionResponseData;
            var output = Encoding.UTF8.GetBytes(isoBytes);
            string base64 = Convert.ToBase64String(output);
            byte[] data = Convert.FromBase64String(base64);
            string decodedString = Encoding.UTF8.GetString(data);

Is there another way to decode the iso-8859-1 to string?

Marc Kenneth Lomio
  • 429
  • 1
  • 4
  • 11
  • 3
    Those `\u00xx` substrings likely represent Unicode characters. For example `\u009c` is "String Terminator", while `\u00ed` is "Latin Small i with Acute". You're going to need more information about how that's encoded – Flydog57 Aug 03 '21 at 05:21
  • 3
    Have you tried using [`Encoding.GetEncoding("ISO-8859-1").GetByes(isoBytes);`](https://stackoverflow.com/a/1922253/15204525) ? – DekuDesu Aug 03 '21 at 05:26
  • @DekuDesu thanks for this. I already tried it. and it seems this is close enough to the expected result. it just needs minor tweak. I will continue in this. – Marc Kenneth Lomio Aug 03 '21 at 05:37

0 Answers0