Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decode UTF8 bytes?

Tags:

c#

encoding

How can I decode UTF8 bytes in a string in C#?

Example: Decode this input:

"Poluci%C3%B3n"

To output this:

"Polución"
like image 809
seldary Avatar asked Mar 04 '26 06:03

seldary


2 Answers

This encoding appears to be URL encoding (not UTF-8 encoding). You can unencode it with a number of different methods in .NET:

HttpUtility.UrlDecode("Poluci%C3%B3n"); // returns "Polución"
Uri.UnescapeDataString("Poluci%C3%B3n"); // returns "Polución"
like image 120
Bradley Grainger Avatar answered Mar 06 '26 20:03

Bradley Grainger


Try this:

Uri.UnescapeDataString("Poluci%C3%B3n")

the problem has nothing to do with UTF8 though. It's just URL encoded.

like image 25
Botz3000 Avatar answered Mar 06 '26 19:03

Botz3000



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!