zoukankan      html  css  js  c++  java
  • What is ANSI format?

    What is ANSI format?

    What is ANSI encoding format? Is it a system default format? In what way does it differ from ASCII?

    回答

    ANSI encoding is a slightly generic term used to refer to the standard code page on a system, usually Windows. It is more properly referred to as Windows-1252 on Western/U.S. systems. (It can represent certain other Windows code pages on other systems.) This is essentially an extension of the ASCII character set in that it includes all the ASCII characters with an additional 128 character codes. This difference is due to the fact that "ANSI" encoding is 8-bit rather than 7-bit as ASCII is (ASCII is almost always encoded nowadays as 8-bit bytes with the MSB set to 0). See the article for an explanation of why this encoding is usually referred to as ANSI.

    The name "ANSI" is a misnomer, since it doesn't correspond to any actual ANSI standard, but the name has stuck. ANSI is not the same as UTF-8.

    可以命令行chcp查看当前的active code page

    Encoding.Default Property

    Different computers can use different encodings as the default, and the default encoding can change on a single computer. If you use the Default encoding to encode and decode data streamed between computers or retrieved at different times on the same computer, it may translate that data incorrectly. In addition, the encoding returned by the Default property uses best-fit fallback to map unsupported characters to characters supported by the code page. For these reasons, using the default encoding is not recommended. To ensure that encoded bytes are decoded properly, you should use a Unicode encoding, such as UTF8Encoding or UnicodeEncoding. You could also use a higher-level protocol to ensure that the same format is used for encoding and decoding.

    The Default property in .NET Framework

    In .NET Framework on the Windows desktop, the Default property always gets the system's active code page and creates a Encoding object that corresponds to it. The active code page may be an ANSI code page, which includes the ASCII character set along with additional characters that vary by code page. Because all Default encodings based on ANSI code pages lose data, consider using the Encoding.UTF8 encoding instead. UTF-8 is often identical in the U+00 to U+7F range, but can encode characters outside the ASCII range without loss.

    The Default property on .NET Core

    On .NET Core, the Default property always returns the UTF8Encoding. UTF-8 is supported on all the operating systems (Windows, Linux, and macOS) on which .NET Core applications run.

  • 相关阅读:
    luogu P3959 宝藏
    hdu4035 Maze
    [hdu2899]Strange fuction
    luogu4407 [JSOI2009]电子字典 字符串hash + hash表
    SPOJ6717 Two Paths 树形dp
    luogu4595 [COCI2011-2012#5] POPLOCAVANJE 后缀自动机
    后缀数组
    luoguP1659 [国际集训队]拉拉队排练 manacher算法
    luoguP4555 [国家集训队]最长双回文串 manacher算法
    CF17E Palisection 差分+manacher算法
  • 原文地址:https://www.cnblogs.com/chucklu/p/14659467.html
Copyright © 2011-2022 走看看