I had successful process that could fetch a CSV stored on OneDrive and separated out the data into an array, importing it into a SharePoint list. But when I modified the trigger to be When an email arrives, I get encoding issues.
The beginning of the process is:
When email arrives
->
Initialise empty String variable (fileContent)
->
Loop (get attachment content)
Set fileContent to attachment content (this is where encoding is off)
-->
Initialise CSV array
value = split(decodeUriComponent(replace(replace(uriComponent(variables('fileContent')),'%0D',''),'%0A','#NL#')),'#NL#')
(--> then, several additional steps that work correctly)
The complex expression in the initialisation of the CSV array is to separate the CSV file into component lines, and converting it into URI components achieved that (at least when the file was on one drive).
The problem I'm having is that the attachment content is being shown as if the encoding is strange. The other steps seem to be working ok but this first step is messing everything up.
If the same CSV file is fetched from OneDrive, it worked. But as an attachment, it's messed up.
The ContentBytes is correct - if I put that output into the base64 decoder, it's correct.
If I copy and paste the odd code in the picture and put that into a different text box, it does seem to convert it to the correct text but not quite perfectly.
I've also tried with and without the extra variable to store the content - if I reference it directly in the array set up, the result is exactly the same.
There doesn't seem to be anything particularly odd about the file. It's UTF16.
I've tried additional base64, base64 to string, etc. Everything always ends up the way it is in the picture.
Thanks for any help you can give!