wannnda 2017-02-23 07:42 采纳率: 0%
浏览 1557

UTF-8和Default这两种转码问题

private static byte[] ComputeHash(HashAlgorithm hashAlgorithm, string inputString)
{
byte[] bytes = Encoding.UTF8.GetBytes(inputString);

        hashAlgorithm.TransformFinalBlock(bytes, 0, bytes.Length);

        return hashAlgorithm.Hash;
    }

                    public static string CRC32(string inputString)
    {
        CRC32 hashAlgorithm = new CRC32();
        hashAlgorithm.Initialize();
        return BytesToStr(ComputeHash(hashAlgorithm, inputString));
    }

            UTF-8不同中文字符串可转化不同编码


            private static byte[] ComputeHash(HashAlgorithm hashAlgorithm, string inputString)
    {
        byte[] bytes = Encoding.Default.GetBytes(inputString);

        hashAlgorithm.TransformFinalBlock(bytes, 0, bytes.Length);

        return hashAlgorithm.Hash;
    }

                    public static string CRC32(string inputString)
    {
        CRC32 hashAlgorithm = new CRC32();
        hashAlgorithm.Initialize();
        return BytesToStr(ComputeHash(hashAlgorithm, inputString));
    }

            Default相同长度中文字符串 转码相同

            UTF-8和Default这两种转码有什么不同
  • 写回答

1条回答 默认 最新

  • threenewbee 2017-02-23 08:15
    关注

    default是什么取决于你操作系统环境的默认编码的设置,如果就是utf8那么就相同,否则就不同

    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏