Send UTF-8 to sed through Run Shell Script in Shortcuts.app


Problem

I want a Shortcut to convert text with diacritical characters like café to ASCII text like cafe, using sed. Here’s a simplified example:

sed -e 'y/é/e/'

This runs fine in Terminal. But when I paste it into the Run Shell Script field in Shortcuts and run, it returns an error “sed: 1: “y/é/e/
“: transform strings are not the same length.”

error dialog

I think the entered script text is fine, because it will continue to work in Terminal if I copy/paste it back from Shortcuts.

I am guessing that Shortcuts decomposes the “é” into two UTF-8 characters “e´” when it sends it to the shell, so the single character counts as two.

Question

How can I enter UTF-8 text with diacritical characters so sed accepts them as single characters?



Source link

Related Posts

About The Author

Add Comment