code: public static String safeEncode(final String stringToEncode) throws StorageException {
          if (stringToEncode == null) {
              return null;
          }
          if (stringToEncode.length() == 0) {
              return Constants.EMPTY_STRING;
          }
  
          try {
              final String tString = URLEncoder.encode(stringToEncode, Constants.UTF8_CHARSET);
  
              if (stringToEncode.contains(" ")) {
                  final StringBuilder outBuilder = new StringBuilder();
  
                  int startDex = 0;
                  for (int m = 0; m < stringToEncode.length(); m++) {
                      if (stringToEncode.charAt(m) == ' ') {
                          if (m > startDex) {
                              outBuilder.append(URLEncoder.encode(stringToEncode.substring(startDex, m),
                                      Constants.UTF8_CHARSET));
                          }
  
                          outBuilder.append("%20");
                          startDex = m + 1;
                      }
                  }
  
                  if (startDex != stringToEncode.length()) {
                      outBuilder.append(URLEncoder.encode(stringToEncode.substring(startDex, stringToEncode.length()),
                              Constants.UTF8_CHARSET));
                  }
  
                  return outBuilder.toString();
              }
              else {
                  return tString;
              }
  
          }
          catch (final UnsupportedEncodingException e) {
              throw Utility.generateNewUnexpectedStorageException(e);
          }
      }
docs: Performs safe encoding of the specified string, taking care to insert <code>%20</code> for each space character,
  instead of inserting the <code>+</code> character.
  
  @param stringToEncode
  A <code>String</code> that represents the string to encode.
  
  @return A <code>String</code> that represents the encoded string.
  
  @throws StorageException
  If a storage service error occurred.