The difference between Encoding.unicode and Encoding.UTF8 in C #

Source: Internet
Author: User

Original address: Click to open the link

See a blog post on the home page today-simply talk about Unicode and UTF-8, and learn that UTF-8 is a way to implement Unicode:

Unicode only provides a uniform binary number for each character in the world, and does not specify how the program should be stored and parsed.

It can be said that UTF-8 is one of the Unicode implementations ...

When this harvest is recorded in Flash memory, @ Asuka _asuka a good question in the reply: "Why are Unicode and UTF8 the two options when choosing the encoding method?" ”

In C #, System.Text.Encoding.Unicode and System.Text.Encoding.UTF8 are 2 ways to encode each other. If UTF-8 is an implementation of Unicode, why is encoding.unicode used as a way to encode UTF8 in C #?

Later on the StackOverflow found the answer:

Windows handles so-called "Unicode" strings as UTF-16 strings, while the most unixes the default to UTF-8 these days.

The original Windows default Unicode implementation is UTF-16, so encoding.unicode in C # is UTF-16.

System.Text.Encoding.Unicode's comments also demonstrate this:


summary://     Gets An encoding for the UTF-16 format using the little endian byte order.////returns://an     encod ing for the UTF-16 format using the little endian byte order.public static Encoding Unicode {get;}

In C #, Encoding.unicode = UTF-16.

The above is the C # Encoding.unicode and Encoding.UTF8 the difference between the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.