Commit: dca0214a17d50a57786a4b081eea71177710d66d
Parent: 95d34e4e4bd6db124014ef28fbce98ae030eedd9
Author: Randy Palamar
Date: Tue, 9 Mar 2021 09:19:58 -0700
ksh: add a toutf8() function
since files encoded in something else usually come from windows the
function also strips line endings
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/.config/ksh/kshrc b/.config/ksh/kshrc
@@ -80,6 +80,15 @@ fix_line_endings() {
done
}
+toutf8() {
+ tmpfile=$(mktemp)
+ for file; do
+ iconv -f $(uchardet "$file") -t UTF-8 $file |\
+ sed s::: >| "$tmpfile"
+ mv "$tmpfile" "$file"
+ done
+}
+
if [ $UNAME == "OpenBSD" ]; then
alias dhclient='doas /sbin/dhclient'
alias ifconfig='doas /sbin/ifconfig'