什么是ANSI编码格式?它是系统默认格式吗? 它和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.
“ANSI”这个名字是不恰当的,因为它不对应任何实际的ANSI标准,但这个名字一直存在。ANSI与UTF-8不同。
其他回答
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.
“ANSI”这个名字是不恰当的,因为它不对应任何实际的ANSI标准,但这个名字一直存在。ANSI与UTF-8不同。
ANSI(又名Windows-1252/WinLatin1)是拉丁字母的字符编码,非常类似于ISO-8859-1。 你可以去维基百科上看看。
当使用单字节字符时,ASCII格式定义了前127个字符。128-255的扩展字符由各种ANSI代码页定义,以允许对其他语言的有限支持。为了理解ANSI编码的字符串,您需要知道它使用哪个代码页。
如果你的电脑不是“西方”电脑,你不知道使用哪个代码页,你可以看看这个页面:国家语言支持(NLS) API参考
[微软删除了此引用,将其从web存档的国家语言支持(NLS) API引用中取出
或者您可以查询您的注册表:
C:\>reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage /f ACP
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage
ACP REG_SZ 1252
End of search: 1 match(es) found.
C:\>
从技术上讲,ANSI应该与US-ASCII相同。它指的是ANSI X3.4标准,这只是ANSI组织批准的ASCII版本。顶部位集字符的使用在ASCII/ANSI中没有定义,因为它是一个7位字符集。
然而,多年来DOS和随后的Windows社区对该术语的误用,已经使其实际含义成为“正在使用的任何机器的系统代码页”。系统码页有时也被称为“mbcs”,因为在东亚系统中,它可以是每个字符多字节编码。一些代码页甚至可以使用顶部清除字节作为多字节序列中的尾随字节,因此它甚至不严格兼容纯ASCII…但即使这样,它仍然被称为“ANSI”。
在美国和西欧的默认设置中,“ANSI”映射到Windows代码页1252。这与ISO-8859-1不同(尽管它们非常相似)。在其他机器上,它可能是其他任何东西。这使得“ANSI”作为外部编码标识符完全无用。
推荐文章
- 我真的需要将“&”编码为“&”吗?
- 用Python写入UTF-8文件
- 撇号的HTML代码
- 将Unicode文本写入文本文件?
- PHP DOMDocument loadHTML没有正确编码UTF-8
- 如何检查Python中的字符串是否是ASCII?
- 什么是ANSI格式?
- 如何在Bash中回显4位Unicode字符?
- 如何从字符串中剥离非ascii字符?(c#)
- 什么是垂直标签?
- 如何转换字符串和从UTF8字节数组在Java
- 将非ascii字符替换为单个空格
- 有一个上下颠倒的插入符号吗?
- 检测编码并使所有内容都为UTF-8
- 导致UnicodeDecodeError: 'utf-8' codec不能解码字节