function encode(input) {
  try {
    return encodeURIComponent(input);
  } catch (e) {
    return null;
  }
}
Attempts to encode a given input.

@param {String} input The string that needs to be encoded.
@returns {String|Null} The encoded string.
@api private