Skip to content

Instantly share code, notes, and snippets.

@ynaoto
Created May 2, 2017 04:48
Show Gist options
  • Save ynaoto/b338051c04a67ba553ba5cc7b255e3e5 to your computer and use it in GitHub Desktop.
Save ynaoto/b338051c04a67ba553ba5cc7b255e3e5 to your computer and use it in GitHub Desktop.
#!/bin/sh
for f in $@
do
opt=$(LANG=C file "$f" |awk '
/Non-ISO extended-ASCII text/ {
print "-f SJIS";
next;
}
/UTF-8/ {
print "";
next;
}
/UTF-16/ {
print "-f UTF-16";
next;
}
{
print "";
}
')
#echo "$f"
iconv $opt "$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment