Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add `escape` function which escapes UTF-8 characters into their 3-byt…

…e format

Example:

    $ escape "♥♡♥"
    \xE2\x99\xA5\xE2\x99\xA1\xE2\x99\xA5
    $ echo -e "\xE2\x99\xA5\xE2\x99\xA1\xE2\x99\xA5"
    ♥♡♥
  • Loading branch information...
commit e3c4b0e821b41f5091d12c1fc1b235a9c9c710f4 1 parent eab8b0b
@mathiasbynens authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 .functions
View
7 .functions
@@ -9,6 +9,7 @@ function httpcompression() {
encoding="$(curl -LIs -H 'User-Agent: Mozilla/5 Gecko' -H 'Accept-Encoding: gzip,deflate,compress,sdch' "$1" | grep '^Content-Encoding:')" && echo "$1 is encoded using ${encoding#* }" || echo "$1 is not using any encoding"
}
+# Syntax-highlight JSON files
function json() {
python -mjson.tool <<< "$*" | pygmentize -l javascript
}
@@ -16,4 +17,10 @@ function json() {
# All the dig info
function digga() {
dig +nocmd "$1" any +multiline +noall +answer
+}
+
+# Escape UTF-8 characters into their 3-byte format
+function escape() {
+ printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u)
+ echo # newline
}
Something went wrong with that request. Please try again.