如何将字符串转换为UTF8? [英] How to convert a string to UTF8?

查看:162
本文介绍了如何将字符串转换为UTF8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一些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);

这篇关于如何将字符串转换为UTF8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆