Search code examples
azurefileazure-logic-appsazure-files

Get File Content from Azure File Storage and special characters


I try to read a csv file in a Logic App from Azure File Storage with Get File Content . The file contains strings with special characters like "æ" and any other danish characters. The result is in the image : enter image description here

Do you have a solution how can I display those special characters? Thanks


Solution

  • To accomplish this, you must first implement base64 encoding to non-Unicode text to transform it to the utf-8 format and then using Azure Functions generate any.NET-supported encoding to UTF-8.Follow is the piece of code that I took from this MSFT - Documentation.

    string requestBody = new StreamReader(req.Body).ReadToEnd();
        dynamic data = JsonConvert.DeserializeObject(requestBody);
    
        if (data == null || data.text == null || data.encodingInput == null || data.encodingOutput == null) {
          return new BadRequestObjectResult("Please pass text/encodingOutput properties in the input JSON object.");
        }
    
        Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
    
        try {
          string encodingInput = data.encodingInput.Value;
          inputEncoding = Encoding.GetEncoding(name: encodingInput);
        } catch (ArgumentException) {
          return new BadRequestObjectResult($"Input character set value '{data.encodingInput.Value}' is not supported. Supported values are
    listed at
    https://msdn.microsoft.com/en-us/library/system.text.encoding(v=vs.110).aspx.");
        }
    
        Encoding encodingOutput = null;
        try {
          string outputEncoding = data.encodingOutput.Value;
          encodingOutput = Encoding.GetEncoding(outputEncoding);
        } catch (ArgumentException) {
          return new BadRequestObjectResult($"Output character set value '{data.encodingOutput.Value}' is not supported. Supported values are
    listed at
    https://msdn.microsoft.com/en-us/library/system.text.encoding(v=vs.110).aspx.");
        }
    
        return (ActionResult) new JsonResult(
          value: new {
            text = Convert.ToBase64String(
              Encoding.Convert(
                srcEncoding: inputEncoding,
                dstEncoding: encodingOutput,
                bytes: Convert.FromBase64String((string) data.text)))
          });   } } ```
    

    for more information please refer Support non-Unicode character encoding in Logic Apps.