# File temp/text.rb, line 382
    def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil )
      string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) { |ref|
        if ref[1] == ?#
          if ref[2] == ?x
            [ref[3...-1].to_i(16)].pack('U*')
          else
            [ref[2...-1].to_i].pack('U*')
          end
        elsif ref == '&'
          '&'
        elsif filter and filter.include?( ref[1...-1] )
          ref
        elsif doctype
          doctype.entity( ref[1...-1] ) or ref
        else
          entity_value = DocType::DEFAULT_ENTITIES[ ref[1...-1] ]
          entity_value ? entity_value.value : ref
        end
      }
    end