Sha256: 0ed6499b22be5bbfe9a79b0180c450956bc87b6b468e22414c1177e131ac6b0f

Contents?: true

Size: 1.7 KB

Versions: 338

Compression:

Stored size: 1.7 KB

Contents

#include <xml_encoding_handler.h>

/*
 * call-seq: Nokogiri::EncodingHandler.[](name)
 *
 * Get the encoding handler for +name+
 */
static VALUE get(VALUE klass, VALUE key)
{
  xmlCharEncodingHandlerPtr handler;

  handler = xmlFindCharEncodingHandler(StringValuePtr(key));
  if(handler)
    return Data_Wrap_Struct(klass, NULL, NULL, handler);

  return Qnil;
}

/*
 * call-seq: Nokogiri::EncodingHandler.delete(name)
 *
 * Delete the encoding alias named +name+
 */
static VALUE delete(VALUE klass, VALUE name)
{
  if(xmlDelEncodingAlias(StringValuePtr(name))) return Qnil;

  return Qtrue;
}

/*
 * call-seq: Nokogiri::EncodingHandler.alias(from, to)
 *
 * Alias encoding handler with name +from+ to name +to+
 */
static VALUE alias(VALUE klass, VALUE from, VALUE to)
{
  xmlAddEncodingAlias(StringValuePtr(from), StringValuePtr(to));

  return to;
}

/*
 * call-seq: Nokogiri::EncodingHandler.clear_aliases!
 *
 * Remove all encoding aliases.
 */
static VALUE clear_aliases(VALUE klass)
{
  xmlCleanupEncodingAliases();

  return klass;
}

/*
 * call-seq: name
 *
 * Get the name of this EncodingHandler
 */
static VALUE name(VALUE self)
{
  xmlCharEncodingHandlerPtr handler;

  Data_Get_Struct(self, xmlCharEncodingHandler, handler);

  return NOKOGIRI_STR_NEW2(handler->name);
}

void init_xml_encoding_handler()
{
  VALUE nokogiri = rb_define_module("Nokogiri");
  VALUE klass = rb_define_class_under(nokogiri, "EncodingHandler", rb_cObject);

  rb_define_singleton_method(klass, "[]", get, 1);
  rb_define_singleton_method(klass, "delete", delete, 1);
  rb_define_singleton_method(klass, "alias", alias, 2);
  rb_define_singleton_method(klass, "clear_aliases!", clear_aliases, 0);
  rb_define_method(klass, "name", name, 0);
}

Version data entries

338 entries across 338 versions & 32 rubygems

Version Path
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_encoding_handler.c
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_encoding_handler.c
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_encoding_handler.c
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_encoding_handler.c
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_encoding_handler.c
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_encoding_handler.c
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_encoding_handler.c
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_encoding_handler.c
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_encoding_handler.c
nokogiri-1.6.7.2 ext/nokogiri/xml_encoding_handler.c
nokogiri-1.6.7.2-x86-mingw32 ext/nokogiri/xml_encoding_handler.c
nokogiri-1.6.7.2-x64-mingw32 ext/nokogiri/xml_encoding_handler.c
nokogiri-1.6.7.2-java ext/nokogiri/xml_encoding_handler.c
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/nokogiri-1.6.6.2/ext/nokogiri/xml_encoding_handler.c
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_encoding_handler.c
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/nokogiri-1.6.6.2/ext/nokogiri/xml_encoding_handler.c
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/nokogiri-1.6.6.2/ext/nokogiri/xml_encoding_handler.c
nokogiri-1.6.8.rc1 ext/nokogiri/xml_encoding_handler.c
nokogiri-1.6.8.rc1-x86-mingw32 ext/nokogiri/xml_encoding_handler.c
nokogiri-1.6.8.rc1-x64-mingw32 ext/nokogiri/xml_encoding_handler.c