【发布时间】:2016-09-28 16:02:48
【问题描述】:
我有像“062A0633062A0020”这样的字符串,我想将它转换为合适的波斯语字符串。我该怎么做? (unicode转伊朗系统编码)
【问题讨论】:
我有像“062A0633062A0020”这样的字符串,我想将它转换为合适的波斯语字符串。我该怎么做? (unicode转伊朗系统编码)
【问题讨论】:
您可以使用 .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); // تست
【讨论】: