Skip to content

Instantly share code, notes, and snippets.

@libc
Created December 30, 2009 21:40
Show Gist options
  • Save libc/266416 to your computer and use it in GitHub Desktop.
Save libc/266416 to your computer and use it in GitHub Desktop.
diff --git a/ext/nokogiri/html_sax_parser_context.c b/ext/nokogiri/html_sax_parser_context.c
index be1ea23..f09b901 100644
--- a/ext/nokogiri/html_sax_parser_context.c
+++ b/ext/nokogiri/html_sax_parser_context.c
@@ -25,9 +25,9 @@ static VALUE parse_memory(VALUE klass, VALUE data, VALUE encoding)
);
if(RTEST(encoding)) {
- xmlCharEncoding enc = xmlParseCharEncoding(StringValuePtr(encoding));
- if(enc != XML_CHAR_ENCODING_ERROR) {
- xmlSwitchEncoding(ctxt, enc);
+ xmlCharEncodingHandlerPtr enc = xmlFindCharEncodingHandler(StringValuePtr(encoding));
+ if(enc != NULL) {
+ xmlSwitchToEncoding(ctxt, enc);
if(ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
rb_raise(rb_eRuntimeError, "Unsupported encoding %s",
StringValuePtr(encoding));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment