gpt4 book ai didi

c# - Windows Phone 7 中的 ASCII 编码

转载 作者:IT王子 更新时间:2023-10-29 04:40:54 25 4
gpt4 key购买 nike

有没有办法在 Windows Phone 7 中使用 ASCIIEncoding?

除非我做错了什么 Encoding.ASCII 不存在,我需要它用于 C# -> PHP 加密(因为 PHP 仅在 SHA1 加密中使用 ASCII)。

有什么建议吗?

最佳答案

自己很容易实现,Unicode 永远不会混淆 ASCII 码:

    public static byte[] StringToAscii(string s) {
byte[] retval = new byte[s.Length];
for (int ix = 0; ix < s.Length; ++ix) {
char ch = s[ix];
if (ch <= 0x7f) retval[ix] = (byte)ch;
else retval[ix] = (byte)'?';
}
return retval;
}

关于c# - Windows Phone 7 中的 ASCII 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4022281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com