asp教程.net 10进制字符串转换为十六进制字符串
public string strtohex(string mstr) //返回处理后的十六进制字符串
{
return bitconverter.tostring(
asciiencoding.default.getbytes(mstr)).replace("-", " ");
} /* strtohex */
16进制字符串转换为10进制字符串
public string hextostr(string mhex) // 返回十六进制代表的字符串
{
mhex = mhex.replace(" ", "");
if (mhex.length <= 0) return "";
byte[] vbytes = new byte[mhex.length / 2];
for (int i = 0; i < mhex.length; i += 2)
if (!byte.tryparse(mhex.substring(i, 2), numberstyles.hexnumber, null, out vbytes[i / 2]))
vbytes[i / 2] = 0;
return asciiencoding.default.getstring(vbytes);
} /* hextostr */
字符串转换为宽字符
public static string stringtowchar(string s)
{
stringbuilder outs = new stringbuilder();
foreach (char item in s)
{
if (isencoding(item))//判断是否编码
{
outs.append(string.format("u{0:x4}", (int)item));
}
else//不是中文
{
outs.append(item);
}
}
return outs.tostring();
}
private static bool isencoding(char cha)
{
string nonencodingchats = "abcdefghijklmnopqrstuvwxyz0123456789`!@#$%^&*()_+|-=,./;'[]{}:<>?";
return nonencodingchats.indexof(cha) == -1;
}
掌握excel表格数据分类汇总实用技巧,提升工作效率和数据分析能力
我把前端从 /ais 改到 /kb 后,连续踩了 7 个 Nginx 坑(含 405/413/502/404 终极解法)
Iptables防火墙connlimit与time模块扩展匹配规则实用指南
VPS 网络质量如何测?一篇讲清楚多节点 ping、tcping 和回程路由
酷开系统5.5真实体验
自我总结ai与个人成长实践思考_知识传播的重要性(3篇)