【问题标题】:Convert an Array of Bytes to Persian string [closed]将字节数组转换为波斯字符串 [关闭]
【发布时间】:2016-09-28 16:02:48
【问题描述】:

我有像“062A0633062A0020”这样的字符串,我想将它转换为合适的波斯语字符串。我该怎么做? (unicode转伊朗系统编码)

【问题讨论】:

    标签: c# unicode encoding


    【解决方案1】:

    您可以使用 .Net Frameowrk 库(System.Text):

    public static byte[] StringToByteArray(string hex)
    {
        return Enumerable.Range(0, hex.Length)
                         .Where(x => x % 2 == 0)
                         .Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
                         .ToArray();
    }
    
    
    byte[] a = StringToByteArray("062A0633062A0020");
    char[] c = System.Text.Encoding.BigEndianUnicode.GetChars(a); // تست
    

    【讨论】:

      猜你喜欢
      • 2017-02-07
      • 1970-01-01
      • 1970-01-01
      • 2013-09-17
      • 2021-05-24
      • 2021-11-11
      • 1970-01-01
      • 2022-01-14
      • 1970-01-01
      相关资源
      最近更新 更多