public
Created

handle non-utf8 encoded XML files

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
case S.PROC_INST_ENDING:
if (c === ">") {
emitNode(parser, "onprocessinginstruction", {
name : parser.procInstName,
body : parser.procInstBody
})
if (parser.procInstName === "xml") {
var match = parser.procInstBody.match(/encoding\s*=\s*['"]([A-Za-z_0-9-]+)['"]/)
if (match) parser.encoding = match[1]
}
parser.procInstName = parser.procInstBody = ""
parser.state = S.TEXT
} else {
parser.procInstBody += "?" + c
parser.state = S.PROC_INST_BODY
}
continue

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.