Created
July 13, 2015 16:03
-
-
Save iegik/be31c339d1a109d79d19 to your computer and use it in GitHub Desktop.
Converts original charset of the file to UTF-8
This file contains hidden or 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
| #!/bin/sh | |
| # Converts original charset of the file to UTF-8 | |
| # require iconv, tr, grep | sed | awk | |
| # grep wins: https://davidlyness.com/post/the-functional-and-performance-differences-of-sed-awk-and-other-unix-parsing-utilities | |
| # grep -oe'[^=]*$' | |
| # sed 's/[^=]*[=]//g' | |
| # awk -F= '{print$2}' | |
| for arg in "$@"; do | |
| TMP=".${arg##*/}.$$"; | |
| iconv -f `file -bi $arg | grep -oe'[^=]*$'` -t UTF-8 $arg | tr -d '\r' > $TMP | |
| mv $TMP $arg; | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment