encodeURIComponent static method

String encodeURIComponent(
  1. String s
)

Implementation

static String encodeURIComponent(String s) {
  String result;

  try {
    result = Uri.encodeComponent(s)
        .replaceAll('\\+', '%20')
        .replaceAll('\\%21', '!')
        .replaceAll('\\%27', "'")
        .replaceAll('\\%28', '(')
        .replaceAll('\\%29', ')')
        .replaceAll('\\%7E', '~');
  } catch (e) {
    result = s;
  }

  return result;
}