First working function to set the charset of a file.