C#NET使用指定的字符集将缓冲区编码为字符串
标签:字符集 var uil turn sum app current stringbu 字符
///
/// 使用指定的字符集将缓冲区编码为字符串。
///
/// 输入缓冲区
/// 字符集.
/// 编码字符串.
public static string EncodeString(byte[] buff, char[] charset) {
int current = buff[0];
var ret = new StringBuilder();
for (int i = 1; i ) {
current = (current 8) + buff[i];
while (current >= charset.Length) {
ret.Append(charset[current % charset.Length]);
current /= charset.Length;
}
}
if (current != 0)
ret.Append(charset[current % charset.Length]);
return ret.ToString();
}
C#NET使用指定的字符集将缓冲区编码为字符串
标签:字符集 var uil turn sum app current stringbu 字符
原文地址:https://www.cnblogs.com/wz2988/p/12416528.html
评论