Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhaofeng233 committed 2021-03-11 00:11:47 +08:00
commit aac5fc9f07
26 files changed
+644 -59

No files matched your search

+13
View File
@@ -12,6 +12,19 @@ import encoding.VlInt;
*/
public class ByteHelper {
/**
* 获取从start到末尾的字节数组
* @param buffer
* @param startIndex
* @return
*/
public static byte[] getTailBytes(byte[] buffer,int startIndex){
int len=buffer.length-startIndex;
byte[] newBytes=new byte[len];
System.arraycopy(buffer,startIndex,newBytes,0,len);
return newBytes;
}
/**
* 从byte[]数组指定开始位置获取第一个字节
* todo: start位置可能是大于int类型的数值
+40
View File
@@ -0,0 +1,40 @@
package util;
/*
* @Author: Wang Feng
* @Description:
* @Version: 1.0.0
* @Date: 11:27 2021/3/10
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
*/
public class StringHelper {
/**
* 对字符串实施百分号编码
* // @Description:
* // 1. 具体编码的定义参见:RFC 3986 section 2
* // 2. 将除了字母('a'~'z', 'A'~'Z')、数字('0' ~ '9')和指定特殊字符('-', '.', '_', '~')
* // 之外的所有字符都进行百分号编码。
* // 3. 对字符串中的每个UTF-8字符c(用八位一个字节表示)进行如下规则的编码:
* // a. 首先将一个八位字节分为两个部分,hi = (c % 0xf0) >> 4 ; lo = c % 0xf。hi 和 lo 均为两个字节表示的数字,范围为(0~15)
* // b. 然后分别用 hi 和 lo 作为索引,从 "0123456789ABCDEF" 字符串取指定位置的字符,最后编码的结果如下表示:
* // '%' + "0123456789ABCDEF"[hi] + "0123456789ABCDEF"[lo]
* // c. 相当于每个需要编码的字符都编码成了一个%开头的三个字符表示
* @param str
* @return
*/
public static String escape(String str){
return "";
}
/**
* 对字符串实施百分号解码
* @param str
* @return
*/
public static String unescape(String str){
return "";
}
}