Try GB2312 before UTF-8. Don't ask about the commented-out snippet.
Add exception handling and system error messages.