R – encode string to utf8

encodeneturlencode

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

Best Answer

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

HttpUtility.UrlEncode(value)