Created
January 5, 2016 19:59
-
-
Save deadbok/a9374fcd83cfa289a54b to your computer and use it in GitHub Desktop.
Add Byte Orders Mark to subtitles
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/bash | |
# addbom.sh | |
FILE=$1 | |
check() | |
{ | |
if (( e = "$1" )); then | |
echo "ERROR: $ACTION failed!!" | |
exit $e | |
else | |
echo "INFO: $ACTION Success!!" | |
fi | |
} | |
set_bom() { | |
ACTION="Setting utf-8 BOM" | |
# Detect if BOM already exists | |
BOM=`sed -n '1{/^\xEF\xBB\xBF/p}' $FILE` | |
if [ -z $BOM ]; then | |
[ -f "$FILE" ] && /usr/bin/vim -e -s +"set bomb|set encoding=utf-8|wq" $FILE | |
check $? | |
fi | |
} | |
set_bom |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment