Class: UriEncoding::Decoder

Inherits:
Object
  • Object
show all
Defined in:
lib/uri_encoding/decoder.rb

Constant Summary collapse

EncodedCharRegexp =
/^%([0-9A-Fa-f]{2})$/

Instance Method Summary collapse

Instance Method Details

#decode(str, encoding = nil) ⇒ Object



5
6
7
8
9
# File 'lib/uri_encoding/decoder.rb', line 5

def decode(str, encoding=nil)
  single_byte_expressions = split_encoded_string(str)
  bytes_string = single_byte_expressions.map{|e| convert_to_byte(e) }.join
  bytes_string.force_encoding(encoding || str.encoding)
end