Support non-Unicode character encoding in Azure Logic Apps
Članak
Applies to: Azure Logic Apps (Consumption + Standard)
When you work with text payloads, Azure Logic Apps infers the text is encoded in a Unicode format, such as UTF-8. You might have problems receiving, sending, or processing characters with different encodings in your workflow. For example, you might get corrupted characters in flat files when working with legacy systems that don't support Unicode.
To work with text that has other character encoding, apply base64ToBinary encoding to the non-Unicode payload. This step prevents Azure Logic Apps from assuming the text is in UTF-8 format. You can then convert any .NET-supported encoding to UTF-8 using Azure Functions.
First, check that your trigger can correctly identify the content type. This step ensures that Azure Logic Apps no longer assumes the text is UTF-8.
In triggers and actions that have the property Infer Content Type, select No. You can usually find this property in the operation's Advanced parameters list. However, if the operation doesn't include this property, the content type is set by the inbound message.
The following list shows some of the connectors where you can disable automatically inferring the content type:
If you're using the Request trigger for text/plain content, you must set the charset parameter that is in the call's Content-Type header. Otherwise, characters might become corrupted, or the parameter doesn't match the payload's encoding format. For more information, review how to handle the text/plain content type.
For example, the HTTP trigger converts the incoming content to UTF-8 when the Content-Type header is set with the correct charset parameter:
If you need to send a non-Unicode payload from your workflow, do the steps for converting the payload to UTF-8 in reverse. Keep the text in UTF-8 as long as possible within your system. Next, use the same function to convert the base64-encoded UTF-8 characters to the required encoding. Then, apply base64 decoding to the text, and send your payload.
When you consume the return value from Azure Functions, make sure to use the base64ToBinary function, not the base64ToString function.
Convert payloads for AS2
You can also use this solution with non-Unicode payloads in the AS2 v2 connector. If you don't convert payloads that you pass to AS2 to UTF-8, you might experience problems with the payload interpretation. These problems might result in a mismatch with the MIC hash between the partners because of misinterpreted characters.
Pridružite se seriji susreta kako biste s kolegama programerima i stručnjacima izgradili skalabilna rješenja umjetne inteligencije temeljena na stvarnim slučajevima upotrebe.