小编Moh*_*sen的帖子

将波斯语 unicode 转换为 Ascii

我需要获取波斯字符串的 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)

encoding ascii persian

6
推荐指数
1
解决办法
5691
查看次数

如何将带有反斜杠的字符串与另一个字符串连接

如何连接字符串"\u""a string"获得“\u0000”?

我的代码创建两个反斜杠:

string a = @"\u" + "0000";  //ends up being "\\\u0000";
Run Code Online (Sandbox Code Playgroud)

c# join backslash

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

ascii ×1

backslash ×1

c# ×1

encoding ×1

join ×1

persian ×1