Fix a bug that renders UTF-8 text files incorrectly when loaded from media. Contributed by @TheStranjer.