Browse Source

Add simple Quoted-Printable encoding/decoding function

Alois Mahdal 6 years ago
parent
commit
5e8dc77f1b
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      dotfiles/bash/main.bashrc

+ 12
- 0
dotfiles/bash/main.bashrc View File

@@ -274,6 +274,18 @@ nljoin() {
274 274
       | fixnl -c
275 275
 }
276 276
 
277
+qpr() {
278
+    #
279
+    # Encode or decode (if $1 is '-d') message on stdin as Quoted Printable
280
+    #
281
+    local fn=encode
282
+    case $1 in
283
+        -d) fn=decode ;;
284
+        -*) echo 'usage: qpr [-d] <text' >&2; return 2 ;;
285
+    esac
286
+    perl -MMIME::QuotedPrint -pe "\$_=MIME::QuotedPrint::$fn(\$_);"
287
+}
288
+
277 289
 xop() {
278 290
     #
279 291
     # Common clipboard operations with fixnl() on top