@exodus/bytes
    Preparing search index...

    Function percentEncodeAfterEncoding

    • Implements percent-encode after encoding per WHATWG URL specification.

      Important

      You must import @exodus/bytes/encoding.js for this API to accept legacy multi-byte encodings.

      Encodings utf16-le, utf16-be, and replacement are not accepted.

      C0 control percent-encode set is always percent-encoded.

      percentEncodeSet is an addition to that, and must be a string of unique increasing codepoints in range 0x20 - 0x7e, e.g. ' "#<>'.

      This method accepts DOMStrings and converts them to USVStrings. This is different from e.g. encodeURI and encodeURIComponent which throw on surrogates:

      > percentEncodeAfterEncoding('utf8', '\ud800', ' "#$%&+,/:;<=>?@[\\]^`{|}') // component
      '%EF%BF%BD'
      > encodeURIComponent('\ud800')
      Uncaught URIError: URI malformed

      Parameters

      • encoding: string

        The encoding label per WHATWG Encoding spec

      • input: string

        Input scalar-value string to encode

      • percentEncodeSet: string

        A string of ASCII chars to escape in addition to C0 control percent-encode set

      • OptionalspaceAsPlus: boolean

        Whether to encode space as '+' instead of '%20' or ' ' (default: false)

      Returns string

      The percent-encoded string