method
unnormalize
v2_5_5 -
Show latest stable
- Class:
REXML::Parsers::BaseParser
unnormalize( string, entities=nil, filter=nil )public
Unescapes all possible entities
# File lib/rexml/parsers/baseparser.rb, line 476
def unnormalize( string, entities=nil, filter=nil )
rv = string.clone
rv.gsub!( /\r\n?/, "\n" )
matches = rv.scan( REFERENCE_RE )
return rv if matches.size == 0
rv.gsub!( /�*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {
m=$1
m = "0#{m}" if m[0] == xx
[Integer(m)].pack('U*')
}
matches.collect!{|x|x[0]}.compact!
if matches.size > 0
matches.each do |entity_reference|
unless filter and filter.include?(entity_reference)
entity_value = entity( entity_reference, entities )
if entity_value
re = /&#{entity_reference};/
rv.gsub!( re, entity_value )
else
er = DEFAULT_ENTITIES[entity_reference]
rv.gsub!( er[0], er[2] ) if er
end
end
end
rv.gsub!( /&/, '&' )
end
rv
end Related methods
- Instance methods
- add_listener
- empty?
- entity
- has_next?
- normalize
- peek
- position
- pull
- stream=
- unnormalize
- unshift
- Class methods
- new
- Private methods
-
need_source_encoding_update? -
pull_event