如何将字符串转换为UTF8?转换为、字符串、如何将

2023-09-03 06:33:50 作者:床上好声音╮

我有一个包含一些UNI code,我怎么把它转换为UTF-8编码字符串?

I have a string that contains some unicode, how do I convert it to UTF-8 encoding?

推荐答案

这个片段使得字节与您的字符串连接在codeD UTF-8的数组:

This snippet makes an array of bytes with your string encoded in UTF-8:

UTF8Encoding utf8 = new UTF8Encoding();
string unicodeString = "Quick brown fox";
byte[] encodedBytes = utf8.GetBytes(unicodeString);
 
精彩推荐
图片推荐