Add ascii-tyrant.sh
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 15 Feb 2010 22:19:31 +0000 (14:19 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 15 Feb 2010 22:19:31 +0000 (14:19 -0800)
ascii-tyrant.sh strips non-ascii characters from text files.

ascii-tyrant.sh [new file with mode: 0755]

diff --git a/ascii-tyrant.sh b/ascii-tyrant.sh
new file mode 100755 (executable)
index 0000000..828e944
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# 1. translate curly single quotes into regular single quotes
+# 2. translate other kind of curly single quotes into regular single quotes
+# 3. translate em-dashes into '--'
+# 4. translate curly start double quotes into regular double quotes
+# 5. translate curly end double quotes into regular double quotes
+cat | \
+sed "s/\xe2\x80\x98/'/" | \
+sed "s/\xe2\x80\x99/'/" | \
+sed "s/\xe2\x80\x93/--/" | \
+sed 's/\xe2\x80\x9c/"/' | \
+sed 's/\xe2\x80\x9d/"/' | \
+cat -
+