{"id":3209,"date":"2020-10-26T15:26:05","date_gmt":"2020-10-26T07:26:05","guid":{"rendered":"https:\/\/www.aoisnow.net\/blog\/?p=3209"},"modified":"2020-10-26T15:26:05","modified_gmt":"2020-10-26T07:26:05","slug":"tont-33593-%e4%b8%ba%e4%bb%80%e4%b9%88-oem-%e4%bb%a3%e7%a0%81%e9%a1%b5%e7%bb%8f%e5%b8%b8%e8%a2%ab%e7%a7%b0%e4%bd%9c-ansi%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.aoisnow.net\/blog\/archives\/3209","title":{"rendered":"TONT 33593 \u4e3a\u4ec0\u4e48 OEM \u4ee3\u7801\u9875\u7ecf\u5e38\u88ab\u79f0\u4f5c ANSI\uff1f"},"content":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20051027-37\/?p=33593\" target=\"_blank\" rel=\"noopener\">https:\/\/devblogs.microsoft.com\/oldnewthing\/20051027-37\/?p=33593<\/a><\/p>\n<p>It has been pointed out that the documentation for the cmd.exe program says<\/p>\n<p>Cmd.exe \u7684\u6587\u6863\u4e2d\u66fe\u6307\u51fa\uff0c<\/p>\n<blockquote><p>\/A Causes the output of internal commands to a pipe or file to be ANSI<\/p>\n<p>\/A \u9009\u9879\u4f7f\u5185\u90e8\u547d\u4ee4\u8f93\u51fa\u81f3\u7ba1\u9053\u6216\u6587\u4ef6\u65f6\u4f7f\u7528 ANSI<\/p><\/blockquote>\n<p>even though the output is actually in the OEM code page. Why do errors such as this persist?<\/p>\n<p>\u2014\u2014\u4e0d\u8fc7\u5b9e\u9645\u4e0a\u662f\u7528 OEM \u4ee3\u7801\u9875\u8f93\u51fa\u7684\uff0c\u4e3a\u4ec0\u4e48\u8fd9\u79cd\u9519\u8bef\u4f1a\u4e0d\u65ad\u51fa\u73b0\u5462\uff1f<\/p>\n<p>Because ANSI sometimes means OEM.<\/p>\n<p>\u56e0\u4e3a ANSI \u6709\u65f6\u5019\u6307\u7684\u5c31\u662f OEM\u3002<\/p>\n<p>The \u201cA\u201d versions of the console functions accept characters in the OEM code page despite the \u201cA\u201d suffix that would suggest ANSI. What\u2019s more, if you call the SetFileAPIsToOEM function, then \u201cA\u201d functions that accept file names will also interpret the filenames in the OEM code page rather than the ANSI code page.<\/p>\n<p>\u300eA\u300f\u7248\u672c\u7684\u63a7\u5236\u53f0\u51fd\u6570\u63a5\u53d7\u5728 OEM \u4ee3\u7801\u9875\u4e2d\u7684\u5b57\u7b26\uff0c\u5373\u4fbf\u300eA\u300f\u8fd9\u4e2a\u524d\u7f00\u6307\u7684\u662f ANSI \u4e5f\u4e00\u6837\u3002\u6b64\u5916\uff0c\u5982\u679c\u4f60\u8c03\u7528 SetFileAPIsToOEM \u8fd9\u4e2a\u51fd\u6570\uff0c\u90a3\u4e48\u63a5\u53d7\u4f20\u5165\u6587\u4ef6\u540d\u7684\u300eA\u300f\u7cfb\u7684\u51fd\u6570\u540c\u6837\u4f1a\u4f7f\u7528 OEM \u4ee3\u7801\u9875\u3001\u800c\u4e0d\u662f ANSI \u4ee3\u7801\u9875\u6765\u89e3\u6790\u6587\u4ef6\u540d\u3002<\/p>\n<p>\u201cThere 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.\u201d<\/p>\n<p>\u300e\u8fd9\u4e16\u4e0a\u6709\u4e24\u79cd\u4eba\uff1a\u76f8\u4fe1\u4eba\u4eec\u53ef\u4ee5\u88ab\u5206\u6210\u4e24\u79cd\u4eba\u7684\uff0c\u548c\u4e0d\u76f8\u4fe1\u7684\u3002\u300f<\/p>\n<p>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 \u201cW\u201d functions (Unicode) and \u201cA\u201d functions (ANSI). There are no \u201cO\u201d functions (OEM). Instead, the OEM folks got lumped in with the ANSI folks.<\/p>\n<p>\u8fd9\u4e16\u4e0a\u4e5f\u6709\u5728\u7cbe\u795e\u4e0a\u5c06\u5b57\u7b26\u4e16\u754c\u4e00\u5206\u4e3a\u4e8c\u7684\u4eba\uff1a\u4e0d\u662f Unicode \u5c31\u662f 8 \u4f4d\u5b57\u7b26\u96c6\u3002\u5e76\u4e14\u4e0e\u6b64\u540c\u65f6\uff0c\u8fd9\u7c7b\u4eba\u4e2d\u7684\u8bb8\u591a\u4e5f\u4e0e Win32 \u7684\u539f\u59cb\u8bbe\u8ba1\u76f8\u5173\u8054\u3002\u6709\u300eW\u300f\u7cfb\u51fd\u6570\uff08Unicode\uff09\uff08\u8bd1\u6ce8\uff1aW \u6307 Wide\uff09\uff0c\u4e5f\u6709\u300eA\u300f\u7cfb\u51fd\u6570\uff08ANSI\uff09\uff0c\u5c31\u662f\u6ca1\u6709\u300eO\u300f\u7cfb\u51fd\u6570\uff08OEM\uff09\uff0cOEM \u5b57\u7b26\u96c6\u7684\u8ba4\u540c\u8005\u4eec\u88ab\u4e0e ANSI \u5b57\u7b26\u96c6\u7684\u62e5\u8db8\u4eec\u64ae\u6210\u4e86\u4e00\u5806\u3002<\/p>\n<p>There are also those who realize the distinction, but out of laziness or convenience often use \u201cANSI\u201d as an abbreviation for \u201can appropriate 8-bit character set, determined from context\u201d. In the context of console programming, the appropriate 8-bit character set is the OEM character set.<\/p>\n<p>\u8fd9\u4e16\u4e0a\u4e5f\u6709\u4eba\u80fd\u5206\u6e05\uff08\u8fd9\u4e09\u79cd\u5b57\u7b26\u96c6\uff09\u7684\u533a\u522b\uff0c\u4f46\u51fa\u4e8e\u61d2\u60f0\u6216\u4fbf\u5229\uff0c\u7ecf\u5e38\u4f7f\u7528\u300eANSI\u300f\u6765\u6307\u4ee3\u300e\u67d0\u79cd8\u4f4d\u5b57\u7b26\u96c6\uff08\u4f9d\u636e\u4e0a\u4e0b\u6587\u6765\u786e\u5b9a\uff09\u300f\u3002\u5728\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\u7684\u4e0a\u4e0b\u6587\u4e2d\uff0c\u5bf9\u5e94\u76848\u4f4d\u5b57\u7b26\u96c6\u6307\u7684\u5c31\u662f OEM \u5b57\u7b26\u96c6\u3002<\/p>\n<p>The person who wrote the online help for cmd.exe clearly meant ANSI to mean \u201cThat thing that isn\u2019t Unicode.\u201d<\/p>\n<p>\u7ed9 cmd.exe \u64b0\u5199\u7ebf\u4e0a\u5e2e\u52a9\u4fe1\u606f\u7684\u4eba\uff0c\u5b9e\u9645\u4e0a\u60f3\u8ba9 ANSI \u6307\u4ee3\u7684\u662f\u300e\u4e0d\u662f Unicode \u7684\u90a3\u79cd\u5b57\u7b26\u96c6\u300f\u3002<\/p>\n<blockquote><p>\/A Causes the output of internal commands to a pipe or file to be ANSI<\/p>\n<p>\/A\u00a0\u9009\u9879\u4f7f\u5185\u90e8\u547d\u4ee4\u8f93\u51fa\u81f3\u7ba1\u9053\u6216\u6587\u4ef6\u65f6\u4f7f\u7528 ANSI<\/p>\n<p>\/U Causes the output of internal commands to a pipe or file to be Unicode<\/p>\n<p>\/U \u9009\u9879\u4f7f\u5185\u90e8\u547d\u4ee4\u8f93\u51fa\u81f3\u7ba1\u9053\u6216\u6587\u4ef6\u65f6\u4f7f\u7528 Unicode<\/p><\/blockquote>\n<p>I\u2019ll leave you to decide whether this author belongs to the \u201cEverything is either Unicode or ANSI\u201d camp or the \u201cjust being casual\u201d camp.<\/p>\n<p>\u81f3\u4e8e\u5199\u8fd9\u4e2a\u5e2e\u52a9\u4fe1\u606f\u7684\u4eba\u662f\u5c5e\u4e8e\u300e\u8fd9\u4e16\u4e0a\u7684\u5b57\u7b26\u4e0d\u662f Unicode \u5c31\u662f ANSI\u300f\u8fd8\u662f\u300e\u4ffa\u5c31\u7d20\u61d2\u300f\u9635\u8425\u7684\uff0c\u5c31\u7559\u5f85\u60a8\u81ea\u884c\u8bc4\u8bf4\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/devblogs.microsoft.com\/oldnewthing\/2005102 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-3209","post","type-post","status-publish","format-standard","hentry","category-tont_history"],"_links":{"self":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/3209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/comments?post=3209"}],"version-history":[{"count":0,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/3209\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/media?parent=3209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/categories?post=3209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/tags?post=3209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}