EN code字符串为utf8字符串、EN、code

2023-09-07 00:39:44 作者:我年轻我任性

如何可以轻松连接codeA字符串中使用.NET(VB或C#)为utf8? 比如我需要连接像这(是)我的字符串codeA串的结果应该是一个字符串+%28is%29 +我+字符串。

How can easily encode a string to utf8 using .NET (VB or C#)? For instance I need to encode a string like "This (is) my string" the result should be a string "This+%28is%29+my+string".

TIA

JP

推荐答案

这是URL编码,而不是UTF8编码。试试这个方法:

This is URL encoding, not UTF8 encoding. Try this method:

HttpUtility.UrlEncode(value)