Skip to content

Instantly share code, notes, and snippets.

@GabrielGuedess
Created June 9, 2023 23:56
Show Gist options
  • Save GabrielGuedess/97b96bb96535541c8a2002bd488d0e0e to your computer and use it in GitHub Desktop.
Save GabrielGuedess/97b96bb96535541c8a2002bd488d0e0e to your computer and use it in GitHub Desktop.
#!/bin/sh
find . -type f -name '*.cs' -exec bash -c '
descr=$(file -b "$0")
if [[ $descr != *UTF-8* ]]; then
iconv -f CP1252 -t UTF-8 "$0" > "$0.$$" && mv "$0.$$" "$0"
elif [[ $descr == *"with BOM"* ]]; then
tail -c +4 "$0" > "$0.$$" && mv "$0.$$" "$0"
fi
' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment