base64编码,URL安全

@param source 被编码的base64字符串
@param charset 字符集
@return 被加密后的字符串
@since 3.0.6
16491
public static String encodeUrlSafe(String source, String charset) {
		return encodeUrlSafe(StrUtil.bytes(source, charset), charset);
	}
1107775
public static String encodeQuery(String url, String charset) throws UtilException {
		return encodeQuery(url, StrUtil.isBlank(charset) ? CharsetUtil.defaultCharset() : CharsetUtil.charset(charset));
	}
755819
public String parse(String source) {
        StringBuffer sbuf = new StringBuffer(source);
        Iterator key_it = argmap.keySet().iterator();

        //skipped = new RangeList();
        // What was this for??
        //process(source, "\"", "\""); // NOI18N
        while (key_it.hasNext()) {
            String it_key = (String) key_it.next();
            String it_obj = formatObject(argmap.get(it_key));
            int it_idx = -1;

            do {
                it_idx = sbuf.toString().indexOf(it_obj, ++it_idx);

                if (it_idx >= 0 /* && !skipped.containsOffset(it_idx) */) {
                    sbuf.replace(it_idx, it_idx + it_obj.length(), ldel + it_key + rdel);

                    //skipped = new RangeList();
                    // What was this for??
                    //process(sbuf.toString(), "\"", "\""); // NOI18N
                }
            } while (it_idx != -1);
        }

        return sbuf.toString();
    }
1020894
public static String decodeStr(String source, String charset) {
		return StrUtil.str(decode(source), charset);
	}
872025
public static String encodeUrlSafe(byte[] source, String charset) {
		return StrUtil.str(encodeUrlSafe(source, false), charset);
	}
120629
@FindbugsSuppressWarnings("DM_DEFAULT_ENCODING")
  public static String encodeBase64(String data) {
    final byte[] encodedBytes = Base64.encodeBase64(data.getBytes());

    return new String(encodedBytes);
  }
523146
public static ImmutableSet<Symbol> loadSymbolSet(final CharSource source) throws IOException {
    return ImmutableSet.copyOf(loadSymbolList(source));
  }
405899
protected void prependBase64EncodedResources(StringBuffer sb, Map<String, Base64EncodedResource> encodedImages) {
		Iterator<Entry<String, Base64EncodedResource>> it = encodedImages.entrySet().iterator();
		StringBuilder mhtml = new StringBuilder();
		String lineSeparator = StringUtils.STR_LINE_FEED;
		mhtml.append("/*!").append(lineSeparator);
		mhtml.append("Content-Type: multipart/related; boundary=\"" + BOUNDARY_SEPARATOR + "\"").append(lineSeparator)
				.append(lineSeparator);

		while (it.hasNext()) {
			Entry<String, Base64EncodedResource> pair = it.next();
			Base64EncodedResource encodedResource = (Base64EncodedResource) pair.getValue();
			mhtml.append(BOUNDARY_SEPARATOR_PREFIX + BOUNDARY_SEPARATOR).append(lineSeparator);
			mhtml.append("Content-Type:").append(encodedResource.getType()).append(lineSeparator);
			mhtml.append("Content-Location:").append(encodedResource.getId()).append(lineSeparator);
			mhtml.append("Content-Transfer-Encoding:base64").append(lineSeparator).append(lineSeparator);
			mhtml.append(encodedResource.getBase64Encoding()).append(lineSeparator).append(lineSeparator);
		}

		mhtml.append(BOUNDARY_SEPARATOR_PREFIX + BOUNDARY_SEPARATOR + BOUNDARY_SEPARATOR_PREFIX).append(lineSeparator);
		mhtml.append("*/").append(lineSeparator).append(lineSeparator);
		sb.insert(0, mhtml.toString());
	}
651536
@Override
    public void setCharacterEncoding(String charset) {
        if (null != this.outWriter || isCommitted()) {
            return;
        }
        if (null != charset) {
            this.encoding = connection.getEncodingUtils().stripQuotes(charset);
        }
        if (null != this.contentType) {
            int index = this.contentType.indexOf("charset=");
            StringBuilder sb = new StringBuilder();
            if (-1 != index) {
                sb.append(this.contentType.substring(0, index - 1).trim());
            } else {
                sb.append(this.contentType);
            }
            if (this.encoding != null) {
                sb.append(";charset=").append(this.encoding);
            }

            this.contentType = sb.toString();
            this.response.setHeader("Content-Type", this.contentType);
        }
    }
1014559
public String encryptBase64(String data, String charset) {
		return Base64.encode(encrypt(data, charset));
	}
52070
public static String toBase64(Object o, String charset, String defaultValue) {
	;
	if (o instanceof byte[]) return toB64((byte[]) o, defaultValue);
	else if (o instanceof String) return toB64((String) o, charset, defaultValue);
	else if (o instanceof Number) return toB64(toString(((Number) o)), charset, defaultValue);
	else if (o instanceof ObjectWrap) {
	    return toBase64(((ObjectWrap) o).getEmbededObject(defaultValue), charset, defaultValue);
	}
	else if (o == null) {
	    return toBase64("", charset, defaultValue);
	}
	else {
	    byte[] b = toBinary(o, null);
	    if (b != null) return toB64(b, defaultValue);
	    else {
		String str = toString(o, null);
		if (str != null) return toBase64(str, charset, defaultValue);
		else return defaultValue;
	    }
	}
    }
968869
public static String decode(String value, Charset charset) {
    try {
      /* there is nothing special between uri and url decoding */
      return URLDecoder.decode(value, charset.name());
    } catch (UnsupportedEncodingException uee) {
      /* since the encoding is not supported, return the original value */
      return value;
    }
  }
1253576
@NotNull
    public static String encode(@NotNull byte[] source) {
        return encode(source, 0, source.length, ALPHABET, true);
    }
92604
public static HttpServletResponse getEncodingResponse(
            HttpServletResponse response, String charset) {
        response.setCharacterEncoding(charset);
        response.setContentType("text/html;charset=" + charset);
        return response;
    }
1244001
public static String encode(byte[] source, String charset) {
		return StrUtil.str(encode(source, false), charset);
	}
639632
protected XmlPullParser loadXml(String source) throws UnsupportedEncodingException, XmlPullParserException, IOException {
		return loadXml(new ByteArrayInputStream(source.getBytes("UTF-8")));
	}
1237703
@Override
    public String encodeBase64(byte[] value) {
        return new String(Base64.encodeBase64(value), Charsets.UTF_8);
    }