Added UTF-8 conversions to prevent database write errors when unusual characters are encountered.