diff options
| author | Daniel Veillard <veillard@src.gnome.org> | 2003-02-04 14:43:39 +0000 |
|---|---|---|
| committer | Daniel Veillard <veillard@src.gnome.org> | 2003-02-04 14:43:39 +0000 |
| commit | e5b110b3844d58ff4bea56bcb699144f6fbe0b83 (patch) | |
| tree | d165d805584bb50c7a2f815aeeafcd33a082ee18 /HTMLparser.c | |
| parent | 419a7688d01dbd4f4234da6bcc57688ae2bb7a4c (diff) | |
| download | android_external_libxml2-e5b110b3844d58ff4bea56bcb699144f6fbe0b83.tar.gz android_external_libxml2-e5b110b3844d58ff4bea56bcb699144f6fbe0b83.tar.bz2 android_external_libxml2-e5b110b3844d58ff4bea56bcb699144f6fbe0b83.zip | |
try to fix # 105049 a couple of changes and extensions updated a function
* HTMLparser.c: try to fix # 105049
* relaxng.c xmlschemastypes.c: a couple of changes and extensions
* tree.c: updated a function comment
Daniel
Diffstat (limited to 'HTMLparser.c')
| -rw-r--r-- | HTMLparser.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/HTMLparser.c b/HTMLparser.c index bc437ed8..186ab09b 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -3927,11 +3927,49 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) { static htmlParserCtxtPtr htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding ATTRIBUTE_UNUSED) { int len; + htmlParserCtxtPtr ctxt; if (cur == NULL) return(NULL); len = xmlStrlen(cur); - return(htmlCreateMemoryParserCtxt((char *)cur, len)); + ctxt = htmlCreateMemoryParserCtxt((char *)cur, len); + + if (encoding != NULL) { + xmlCharEncoding enc; + xmlCharEncodingHandlerPtr handler; + + if (ctxt->input->encoding != NULL) + xmlFree((xmlChar *) ctxt->input->encoding); + ctxt->input->encoding = (const xmlChar *) encoding; + + enc = xmlParseCharEncoding(encoding); + /* + * registered set of known encodings + */ + if (enc != XML_CHAR_ENCODING_ERROR) { + xmlSwitchEncoding(ctxt, enc); + if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) { + if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) + ctxt->sax->error(ctxt->userData, + "Unsupported encoding %s\n", encoding); + ctxt->input->encoding = NULL; + } + } else { + /* + * fallback for unknown encodings + */ + handler = xmlFindCharEncodingHandler((const char *) encoding); + if (handler != NULL) { + xmlSwitchToEncoding(ctxt, handler); + } else { + ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING; + if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) + ctxt->sax->error(ctxt->userData, + "Unsupported encoding %s\n", encoding); + } + } + } + return(ctxt); } /************************************************************************ |
