请注意:本页内容发布于 1490 天前,内容可能已经过时,请注意甄别。
原文链接:https://devblogs.microsoft.com/oldnewthing/20051027-37/?p=33593
It has been pointed out that the documentation for the cmd.exe program says
Cmd.exe 的文档中曾指出,
/A Causes the output of internal commands to a pipe or file to be ANSI
/A 选项使内部命令输出至管道或文件时使用 ANSI
even though the output is actually in the OEM code page. Why do errors such as this persist?
——不过实际上是用 OEM 代码页输出的,为什么这种错误会不断出现呢?
Because ANSI sometimes means OEM.
因为 ANSI 有时候指的就是 OEM。
The “A” versions of the console functions accept characters in the OEM code page despite the “A” suffix that would suggest ANSI. What’s more, if you call the SetFileAPIsToOEM function, then “A” functions that accept file names will also interpret the filenames in the OEM code page rather than the ANSI code page.
『A』版本的控制台函数接受在 OEM 代码页中的字符,即便『A』这个前缀指的是 ANSI 也一样。此外,如果你调用 SetFileAPIsToOEM 这个函数,那么接受传入文件名的『A』系的函数同样会使用 OEM 代码页、而不是 ANSI 代码页来解析文件名。
“There are two types of people in the world: Those who believe that the world can be divided into two types of people, and those who do not.”
『这世上有两种人:相信人们可以被分成两种人的,和不相信的。』
There are those who mentally divide the world of characters into two groups: Unicode and 8-bit. And as you can see, many of them were involved in the original design of Win32. There are “W” functions (Unicode) and “A” functions (ANSI). There are no “O” functions (OEM). Instead, the OEM folks got lumped in with the ANSI folks.
这世上也有在精神上将字符世界一分为二的人:不是 Unicode 就是 8 位字符集。并且与此同时,这类人中的许多也与 Win32 的原始设计相关联。有『W』系函数(Unicode)(译注:W 指 Wide),也有『A』系函数(ANSI),就是没有『O』系函数(OEM),OEM 字符集的认同者们被与 ANSI 字符集的拥趸们撮成了一堆。
There are also those who realize the distinction, but out of laziness or convenience often use “ANSI” as an abbreviation for “an appropriate 8-bit character set, determined from context”. In the context of console programming, the appropriate 8-bit character set is the OEM character set.
这世上也有人能分清(这三种字符集)的区别,但出于懒惰或便利,经常使用『ANSI』来指代『某种8位字符集(依据上下文来确定)』。在控制台应用程序的上下文中,对应的8位字符集指的就是 OEM 字符集。
The person who wrote the online help for cmd.exe clearly meant ANSI to mean “That thing that isn’t Unicode.”
给 cmd.exe 撰写线上帮助信息的人,实际上想让 ANSI 指代的是『不是 Unicode 的那种字符集』。
/A Causes the output of internal commands to a pipe or file to be ANSI
/A 选项使内部命令输出至管道或文件时使用 ANSI
/U Causes the output of internal commands to a pipe or file to be Unicode
/U 选项使内部命令输出至管道或文件时使用 Unicode
I’ll leave you to decide whether this author belongs to the “Everything is either Unicode or ANSI” camp or the “just being casual” camp.
至于写这个帮助信息的人是属于『这世上的字符不是 Unicode 就是 ANSI』还是『俺就素懒』阵营的,就留待您自行评说了。
远嚣 Comment