对字符串进行编码 @param str 需要处理的字符串 @param encoding 编码方式 @return 编码后的字符串
(String str, String encoding)
| 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 | * 对字符串进行解码 |