Created
January 23, 2017 15:40
-
-
Save eliranmal/0a29d0ef1a990e08ac53844b99224200 to your computer and use it in GitHub Desktop.
encode/decode utf strings in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
utf_encode() { | |
printf "\\\x%s" $(printf "$1" | xxd -p -c1 -u) | |
} | |
utf_decode() { | |
printf "%b" "$1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment