module Bundler::URI

def self.encode_www_form_component(str, enc=nil)

Related: Bundler::URI.encode_uri_component (encodes ' ' as '%20').

In either case, the returned string has forced encoding Encoding::US_ASCII.

and then to encoding +enc+.
(with suitable character replacements),
- Otherwise +str+ is converted first to Encoding::UTF_8
- If +str+ has encoding Encoding::ASCII_8BIT, argument +enc+ is ignored.

Encoding:

# => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
Bundler::URI.encode_www_form_component('Here are some punctuation characters: ,;?:')

Example:

the percent notation for character c is '%%%X' % c.ord.
- Any other character to "percent notation";
- Character ' ' to character '+'.

- Converts:

# => "*.-_azAZ09"
Bundler::URI.encode_www_form_component('*.-_azAZ09')

Example:

and '0'..'9'.
- Character in ranges 'a'..'z', 'A'..'Z',
- Characters '*', '.', '-', and '_'.

- Preserves:

The returned string:

Returns a URL-encoded string derived from the given string +str+.
def self.encode_www_form_component(str, enc=nil)
  _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
end