No need for all this trickery. UTF-8 is already detected and used