Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebClient Unicode - Which UTF8?

When I create a WebClient to consume some RESTful xml, I can specify the unicode encoding 2 ways:

WebClient wc = new WebClient (); wc.Encoding = Encoding.UTF8; wc.Encoding = UTF8Encoding.UTF8; 

Which is correct/better ?

like image 674
Ian Vink Avatar asked Nov 23 '10 03:11

Ian Vink


People also ask

Does UTF-8 cover all Unicode?

UTF-8 is a character encoding - a way of converting from sequences of bytes to sequences of characters and vice versa. It covers the whole of the Unicode character set.

Is UTF-8 the same as Unicode?

The Difference Between Unicode and UTF-8Unicode is a character set. UTF-8 is encoding. Unicode is a list of characters with unique decimal numbers (code points).

What is the difference between UTF-8 and UTF-8?

UTF-8 is a valid IANA character set name, whereas utf8 is not. It's not even a valid alias. it refers to an implementation-provided locale, where settings of language, territory, and codeset are implementation-defined.


1 Answers

They're identical.

UTF8Encoding inherits Encoding.
Therefore, you can access all of the static members declared by Encoding through the UTF8Encoding qualifier.

In fact, you can even write ASCIIEncoding.UTF8, and it will still work.

It will compile to identical IL, even in debug mode.


I would recommend using Encoding.UTF8, as it shows what's going on more clearly.

like image 194
SLaks Avatar answered Sep 20 '22 09:09

SLaks