MCPcopy Create free account
hub / github.com/0opslab/opslabJutil / escape

Method escape

src/main/java/com/opslab/helper/WebHelper.java:22–28  ·  view source on GitHub ↗

对字符串进行编码 @param str 需要处理的字符串 @param encoding 编码方式 @return 编码后的字符串

(String str, String encoding)

Source from the content-addressed store, hash-verified

20 * @return 编码后的字符串
21 */
22 public static String escape(String str, String encoding) throws UnsupportedEncodingException {
23 if (StringUtil.isEmpty(str)) {
24 return "";
25 }
26 char[] chars = ConvertHepler.bytesToChars(ConvertHepler.encodeBytes(str.getBytes(encoding), '%'));
27 return new String(chars);
28 }
29
30 /**
31 * 对字符串进行解码

Callers 1

testescapeEncodingMethod · 0.95

Calls 3

isEmptyMethod · 0.95
bytesToCharsMethod · 0.95
encodeBytesMethod · 0.95

Tested by 1

testescapeEncodingMethod · 0.76