html: Process data before switching encoding This reduces the amount of data to convert and avoids issues with EOF detection. Also reset EOF flag after switching encoding as a precaution.