Sample Header Ad - 728x90

Escaping UTF-8 encoded URLs

0 votes
1 answer
319 views
I want to replace a *variable expansion* with a *URL* --- directly inside a file.
The URL I want to replace the variable expansion with is UTF-8 encoded due to the language of its webpage name being Right-To-Left (RTL) [Hebrew]. --- Here is a replaced-replacement pattern I work with (currently without escaping): sed -i 's/$contact_form_success_webpage/https://example.com/index.php?title=%D7%99%D7%A6%D7%99%D7%A8%D7%AA_%D7%A7%D7%A9%D7%A8:%D7%94%D7%A6%D7%9C%D7%97%D7%94/g ' FILE I could add a backslash before the $ of $contact_form_success_webpage so to make it \$contact_form_success_webpage which is processable by sed but to start adding backslashes to needs-to-be-esacped parts of "long" encoded URLs is something I'd rather not do totally by myself and would prefer some automation for that. The above URL pattern is quite "light" or "easy" but some URLs might have lots of forward slashes (/) and perhaps lots of other needs-to-be-escaped parts also. --- **How would you do suggest to escape UTF-8 encoded URLs?**
(What pattern will you use for generally all use cases?)
Asked by timesharer (1 rep)
Mar 30, 2021, 09:46 AM
Last activity: Mar 31, 2021, 01:55 PM