Fixing messed charset in SQL tables

This should be rare but if, when upgraded, extended characters are messed (e.g. á instead of á) here's a procedure to fix them manually. I've only tested it with an UTF-8 console though.

Script

Notes

#!/bin/bash
set -e

CHARS=( á é í ó ú à è ì ò ù Á É Í Ó Ú À È Î Ò Ù ñ Ñ · ¿ ¡ ä ë ï ö ü Ä Ë Ï Ö Ü ç Ç € ¢ £ ¥ ŀ ß æ œ )
TABLES=( oldrecorded oldprogram program record recorded )

echo "Translations:" >&2
for char in ${CHARS[*]}; do
	broken=$(echo $char | iconv -flatin1 -tutf8)
	char=$(echo $char | iconv -tutf8) # For non-UTF-8 systems (not tested)
	echo "$broken -> $char" >&2
done

for table in ${TABLES[*]}; do
	if [ ! -f $table.sql ]; then
		echo "Table $table skipped" >&2
	continue ; fi

	echo "Fixing $table" >&2
	for char in ${CHARS[*]}; do
		broken=$(echo $char | iconv -flatin1 -tutf8)
		char=$(echo $char | iconv -tutf8) # For non-UTF-8 systems (not tested)
		sed -i "s/$broken/$char/g" $table.sql
	done
done
1) note program should fix itself in the next guide updat; can be TRUNCATE'd to be sure and then run mythfilldatabase or wait for the next automatic update