Hacker News new | ask | show | jobs
by josefx 22 days ago
> By "through metadata", you mean with some external separate mechanism unrelated to the XML spec?

The code generating the xml text may not be aware of the final encoding used to store/transmit it and a library writing text to an encoded stream might not be aware that the text it is sending contains xml. So I would say allowing xml to be parsed using an externally specified encoding makes at least some sense.

> A document that initially looks like UTF-8 could be almost any of literally hundreds of encodings including all the common ISO 8859 encodings

Your own link shows that those "hundreds of encodings" are all based on ASCII, which is enough to get the concrete encoding from the declaration.

> and then switch to a "parsing" phase after rewinding to the start of the document.

So one call to fseek(stream, 0, SEEK_SET)?