Last active
July 4, 2020 06:50
-
-
Save marios88/08edab7091b0c48cdc59c70ac62fb4b3 to your computer and use it in GitHub Desktop.
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 | |
# Find the current encoding of the file | |
# place in $HOME/bin | |
# to mass use it | |
# find "$PWD" -type f -name "*" -exec recodeifneeded utf-8 {} \; | |
encoding=$(uchardet "$2") | |
if [[ "$1" != "${encoding}" ]] && [[ "${encoding}" != "UTF-8" ]] && [[ "${encoding}" != "unknown" ]] | |
then | |
# Encodings differ, we have to encode | |
echo "recoding from ${encoding} to $1 file : $2" | |
recode ${encoding}..$1 $2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment