code: private String escape(String value)
      {
          StringBuilder result = new StringBuilder();
          for (int i = 0; i < value.length(); ++i)
          {
              char c = value.charAt(i);
              if (c < reservedChars.length && reservedChars[c] == c)
              {
                  result.append(ESCAPE_PREFIX);
                  int code = c & 0xFF;
                  if (code < 16) result.append("0");
                  result.append(Integer.toHexString(code));
              }
              else
              {
                  result.append(c);
              }
          }
          return result.toString();
      }
docs: Escapes the scope string following RFC 2608, 6.4.1
  
  @param value The scope string to escape
  @return The escaped scope string
  @see #unescape(String)