1ae0515a80686d33406c9a2c58c0c9666ca47c77

Author
Marc Cornellà <marc@mcornella.com>
Committer
GitHub <noreply@github.com>
Date

Message

fix(lib): patch `omz_urlencode` to not encode UTF-8 chars in Termux (#12076)

Fixes #12061

Diff

 1diff --git a/lib/functions.zsh b/lib/functions.zsh
 2index a252d0a330a7aaa05264eb73523878ef0430cab5..f5c671f9c93eebf0fa8b04cffba335cf7c6a5de4 100644
 3--- a/lib/functions.zsh
 4+++ b/lib/functions.zsh
 5@@ -182,6 +182,8 @@ function omz_urlencode() {
 6   fi
 7 
 8   # Use LC_CTYPE=C to process text byte-by-byte
 9+  # Note that this doesn't work in Termux, as it only has UTF-8 locale.
10+  # Characters will be processed as UTF-8, which is fine for URLs.
11   local i byte ord LC_ALL=C
12   export LC_ALL
13   local reserved=';/?:@&=+$,'
14@@ -206,6 +208,9 @@ function omz_urlencode() {
15     else
16       if [[ "$byte" == " " && -n $spaces_as_plus ]]; then
17         url_str+="+"
18+      elif [[ "$PREFIX" = *com.termux* ]]; then
19+        # Termux does not have non-UTF8 locales, so just send the UTF-8 character directly
20+        url_str+="$byte"
21       else
22         ord=$(( [##16] #byte ))
23         url_str+="%$ord"