开发者

How can I convert a Unicode value to an ASCII string?

I am given a Un开发者_运维百科icode value that contains characters that can be represented as ASCII. How can I get a string containing the ASCII characters from the Unicode value?


Take a look at this example here

You would need to covert it by transforming the string into a byte array.


If you have an instance of a string and you want to turn it into an array of bytes containing the values for ASCII characters you can use the GetBytes method of the System.Text.ASCIIEncoding class.


Use the Encoding.Convert Method


string text = "your text";
byte[] asciiBytes = Encoding.Convert(Encoding.Unicode, Encoding.ASCII, Encoding.Unicode.GetBytes(text));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜