def normalize_uri_path_component(path_component):
result = BytesIO()<EOL>i = <NUM_LIT:0><EOL>path_component = path_component.encode("<STR_LIT:utf-8>")<EOL>while i < len(path_component):<EOL><INDENT>c = indexbytes(path_component, i)<EOL>if c in _rfc3986_unreserved:<EOL><INDENT>result.write(int2byte(c))<EOL>i += <NUM_LIT:1><EOL><DEDENT>elif c == _ascii_percent: <EOL><INDENT>if i + <NUM_LIT:2> >= len(path_component):<EOL><INDENT>result.write(b"<STR_LIT>")<EOL>i += <NUM_LIT:1><EOL>continue<EOL><DEDENT>try:<EOL><INDENT>value = int(path_component[i+<NUM_LIT:1>:i+<NUM_LIT:3>], <NUM_LIT:16>)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise ValueError("<STR_LIT>" % i)<EOL><DEDENT>if value in _rfc3986_unreserved:<EOL><INDENT>result.write(int2byte(value))<EOL><DEDENT>else:<EOL><INDENT>result.write(b"<STR_LIT>" % value)<EOL><DEDENT>i += <NUM_LIT:3><EOL><DEDENT>elif c == _ascii_plus:<EOL><INDENT>result.write(b"<STR_LIT>")<EOL>i += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>result.write(b"<STR_LIT>" % c)<EOL>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>result = result.getvalue()<EOL>if not isinstance(result, string_types):<EOL><INDENT>result = str(result, "<STR_LIT:utf-8>")<EOL><DEDENT>return result<EOL>
normalize_uri_path_component(path_component) -> str

Normalize the path component according to RFC 3986.  This performs the
following operations:
* Alpha, digit, and the symbols '-', '.', '_', and '~' (unreserved
  characters) are left alone.
* Characters outside this range are percent-encoded.
* Percent-encoded values are upper-cased ('%2a' becomes '%2A')
* Percent-encoded values in the unreserved space (%41-%5A, %61-%7A,
  %30-%39, %2D, %2E, %5F, %7E) are converted to normal characters.

If a percent encoding is incomplete, the percent is encoded as %25.

A ValueError exception is thrown if a percent encoding includes non-hex
characters (e.g. %3z).