cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
degvalentine
Level: Powered On

How to remove non-ASCII chars, with example of Azure Blob metadata

I recently had a use case to add metadata to an Azure Blob. The metadata value only supports ASCII, so I need to ensure my tokenized content is compatible. Alas, no simple way to convert non-ascii characters (e.g. no regex replace).

 

So, here's my solution: URI-encode the string then restore the non-URL-compatible ASCII characters.

 

Here are the non-URL-compatible ASCII characters we need to restore: 

 !"#$%&'()*+,:;<=>?@[\]^{|}

 

Here's the brute-force nesting of "replace" needed to restore all those chars after URI-encoding:

replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
uriComponent(outputs('myStr')),
'%20', ' '), '%21', '!'), '%22', '"'), '%23', '#'), '%24', '$'), '%25', '%'), '%26', '&'), '%27', ''''), '%28', '('), '%29', ')'), '%2A', '*'), '%2B', '+'), '%2C', ','), '%2F', '/'), '%3A', ':'), '%3B', ';'), '%3C', '<'), '%3D', '='), '%3E', '>'), '%3F', '?'), '%40', '@'), '%5B', '['), '%5C', '\'), '%5D', ']'), '%5E', '^'), '%60', '`'), '%7B', '{'), '%7C', '|'), '%7D', '}')

 

Here's a Flow to show it in action:

2019-09-05 10_51_25-Edit your flow _ Microsoft Flow.png

 

Here's the result (with the "INPUTS" hidden) since it's identical with the Compose action.

2019-09-05 10_51_01-Run History _ Microsoft Flow.png

 

Here's the result with non-ASCII chars URI-encoded:

ALL THE ASCII THINGS: !"#$%&'()*+,-./0123456789:;<=>?@[\]^_`AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz{|}~%0A%0AAND SOME NON-ASCII THINGS, TOO: %F0%9F%92%80%F0%9F%91%BB%F0%9F%91%BD%F0%9F%A4%96%F0%9F%92%A9

 

Now you can safely send your Azure Blob metadata!

2019-09-05 11_03_23-Edit your flow _ Microsoft Flow.png

1 REPLY 1
Highlighted
Administrator
Administrator

Re: How to remove non-ASCII chars, with example of Azure Blob metadata

Hey, @degvalentine!

Thanks so much for your awesome submission to the Microsoft Flow Communtiy CookBook! 

Please feel free to come share your Flow recipes here anytime! 😁

 

Happy Flowing!

-Gabriel

-Gabriel
Microsoft Flow Community Manager

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 46 members 4,510 guests
Please welcome our newest community members: