我需要获取波斯字符串的 ASCII 代码才能在程序中使用它。但是下面的方法给出了?分数: ”??? ????”
public string PerisanAscii()
{
//persian string
string unicodeString = "??? ????";
// Create two different encodings.
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode;
// Convert the string into a byte array.
byte[] unicodeBytes = unicode.GetBytes(unicodeString);
// Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
// Convert the new byte[] into a char[] and then into a string.
char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, …
Run Code Online (Sandbox Code Playgroud) 如何连接字符串"\u"
以"a string"
获得“\u0000”?
我的代码创建两个反斜杠:
string a = @"\u" + "0000"; //ends up being "\\\u0000";
Run Code Online (Sandbox Code Playgroud)