Class: Nokogiri::EncodingHandler
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | ext/nokogiri/xml_encoding_handler.c, lib/nokogiri/encoding_handler.rb |
Constant Summary
-
USEFUL_ALIASES =
# File 'lib/nokogiri/encoding_handler.rb', line 7
Popular encoding aliases not known by all iconv implementations that
::Nokogirishould support.{ # alias_name => true_name "ISO-2022-JP" => "ISO-2022-JP", # only for JRuby tests, this is a no-op in CRuby "NOKOGIRI-SENTINEL" => "ISO-2022-JP", # indicating the Nokogiri has installed aliases "Windows-31J" => "CP932", # Windows-31J is the IANA registered name of CP932. }
Class Method Summary
- .install_default_aliases
- .[](name) Internal use only
-
.alias(real_name, alias_name)
Internal use only
Alias encoding handler with name
real_nameto namealias_name -
.clear_aliases!
Internal use only
Remove all encoding aliases.
-
.delete(name)
Internal use only
Delete the encoding alias named #name
- .new(name) ⇒ EncodingHandler constructor Internal use only
- .storage private Internal use only
Instance Attribute Summary
-
#name
readonly
Internal use only
Get the name of this
EncodingHandler.
Constructor Details
.new(name) ⇒ EncodingHandler
This method is for internal use only.
Class Method Details
.[](name)
This method is for internal use only.
[ GitHub ]
# File 'ext/nokogiri/xml_encoding_handler.c', line 27
static VALUE
rb_xml_encoding_handler_s_get(VALUE klass, VALUE key)
{
xmlCharEncodingHandlerPtr handler;
handler = xmlFindCharEncodingHandler(StringValueCStr(key));
if (handler) {
return TypedData_Wrap_Struct(klass, &xml_char_encoding_handler_type, handler);
}
return Qnil;
}
.alias(real_name, alias_name)
This method is for internal use only.
Alias encoding handler with name real_name to name alias_name
# File 'ext/nokogiri/xml_encoding_handler.c', line 60
static VALUE
rb_xml_encoding_handler_s_alias(VALUE klass, VALUE from, VALUE to)
{
xmlAddEncodingAlias(StringValueCStr(from), StringValueCStr(to));
return to;
}
.clear_aliases!
This method is for internal use only.
Remove all encoding aliases.
# File 'ext/nokogiri/xml_encoding_handler.c', line 74
static VALUE
rb_xml_encoding_handler_s_clear_aliases(VALUE klass)
{
xmlCleanupEncodingAliases();
return klass;
}
.delete(name)
This method is for internal use only.
Delete the encoding alias named #name
# File 'ext/nokogiri/xml_encoding_handler.c', line 46
static VALUE
rb_xml_encoding_handler_s_delete(VALUE klass, VALUE name)
{
if (xmlDelEncodingAlias(StringValueCStr(name))) { return Qnil; }
return Qtrue;
}
.install_default_aliases
[ GitHub ]# File 'lib/nokogiri/encoding_handler.rb', line 15
def install_default_aliases USEFUL_ALIASES.each do |alias_name, name| EncodingHandler.alias(name, alias_name) if EncodingHandler[alias_name].nil? end end
.storage (private)
This method is for internal use only.
[ GitHub ]
# File 'lib/nokogiri/encoding_handler.rb', line 43
def storage @storage ||= {} end
Instance Attribute Details
#name (readonly)
This method is for internal use only.
Get the name of this EncodingHandler
# File 'ext/nokogiri/xml_encoding_handler.c', line 88
static VALUE
rb_xml_encoding_handler_name(VALUE self)
{
xmlCharEncodingHandlerPtr handler;
TypedData_Get_Struct(self, xmlCharEncodingHandler, &xml_char_encoding_handler_type, handler);
return NOKOGIRI_STR_NEW2(handler->name);
}