Fix handling of invalid UTF-8 in mssql05. Closes #830