{"id":3437,"date":"2022-03-02T16:40:29","date_gmt":"2022-03-02T08:40:29","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=3437"},"modified":"2024-05-05T14:19:26","modified_gmt":"2024-05-05T06:19:26","slug":"cmd-%e5%92%8c-powershell-%e8%ae%be%e7%bd%ae-utf-8","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=3437","title":{"rendered":"cmd \u548c PowerShell \u8bbe\u7f6e UTF-8"},"content":{"rendered":"\n<p>\u5bf9\u4e8e\u7ecf\u5e38\u5728 Linux \u4e0b\u5199\u4ee3\u7801\u7684\u4eba\u6765\u8bf4\uff0c\u4e00\u822c\u800c\u8a00\u5b57\u7b26\u7f16\u7801\u90fd\u662f\u8bbe\u7f6e\u7684 UTF-8\uff0c\u5e94\u8be5\u8bf4\u5f88\u591a\u4ee3\u7801\u7f16\u8f91\u5668\u9ed8\u8ba4\u7684\u5b57\u7b26\u7f16\u7801\u5c31\u662f UTF-8\u3002\u4f46\u662f\u5f53\u628a\u4ee3\u7801\u6587\u4ef6\u79fb\u5230 Windows \u4e0b\u7f16\u8bd1\u8fd0\u884c\u53ef\u80fd\u5c31\u4f1a\u51fa\u73b0\u95ee\u9898\uff0c\u4e2d\u6587\u663e\u793a\u4e71\u7801\u3002\u8fd9\u662f\u56e0\u4e3a Windows \u7684 CMD \u548c PowerShell \u9ed8\u8ba4\u7684\u5b57\u7b26\u7f16\u7801\u662f GB2312\uff0c\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6709\u591a\u79cd\u65b9\u5f0f\uff1a<\/p>\n\n\n\n<p><strong>(1) \u4fee\u6539\u7cfb\u7edf\u5b57\u7b26\u7f16\u7801\u8bbe\u7f6e<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"860\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-1024x860.png\" alt=\"\" class=\"wp-image-3438 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-1024x860.png 1024w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-300x252.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-768x645.png 768w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image.png 1147w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/860;\" \/><\/figure>\n\n\n\n<p>\u52fe\u9009 UTF-8 \u786e\u8ba4\u5c31\u884c\uff0c\u4f46\u662f\u5e76\u4e0d\u5efa\u8bae\u3002\u4fee\u6539\u8fd9\u4e2a\u662f\u4e24\u5934\u96be\uff0c\u6216\u8bb8\u4ee3\u7801\u80fd\u6b63\u5e38\u7f16\u8bd1\u8fd0\u884c\u4e86\uff0c\u4f46\u662f\u4e0d\u6392\u9664\u6709\u5b89\u88c5\u7684\u8f6f\u4ef6\u5185\u90e8\u662f GB2312\uff0c\u90a3\u5230\u65f6\u5019\u90a3\u4e9b\u8f6f\u4ef6\u53ef\u80fd\u5c31\u65e0\u6cd5\u6b63\u5e38\u663e\u793a\u6587\u5b57\u4e86\u3002<\/p>\n\n\n\n<p><strong>(2) \u5c06\u4ee3\u7801\u91cd\u65b0\u4fdd\u5b58\uff0c\u8bbe\u7f6e\u5b57\u7b26\u7f16\u7801\u4e3a GB2312<\/strong><\/p>\n\n\n\n<p>\u4f46\u662f\u6587\u4ef6\u5c11\u8fd8\u597d\u8bf4\uff0c\u50cf\u4e00\u4e9b\u9879\u76ee\u5927\u4e00\u70b9\uff0c\u6587\u4ef6\u5c31\u4e0d\u5c11\uff0c\u8fd9\u6837\u4e00\u4e2a\u4e00\u4e2a\u6539\u5f88\u7d2f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"769\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-1-1024x769.png\" alt=\"\" class=\"wp-image-3439 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-1-1024x769.png 1024w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-1-300x225.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-1-768x577.png 768w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-1.png 1090w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/769;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"769\" height=\"397\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-2.png\" alt=\"\" class=\"wp-image-3440 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-2.png 769w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-2-300x155.png 300w\" data-sizes=\"(max-width: 769px) 100vw, 769px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 769px; --smush-placeholder-aspect-ratio: 769\/397;\" \/><\/figure>\n\n\n\n<p><strong>(3) \u4e34\u65f6\u4fee\u6539\u63a7\u5236\u53f0\u5b57\u7b26\u7f16\u7801<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chcp.com 65001<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"327\" height=\"69\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-3.png\" alt=\"\" class=\"wp-image-3441 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-3.png 327w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-3-300x63.png 300w\" data-sizes=\"(max-width: 327px) 100vw, 327px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 327px; --smush-placeholder-aspect-ratio: 327\/69;\" \/><\/figure>\n\n\n\n<p>\u6bcf\u65b0\u6253\u5f00\u4e00\u4e2a\u90fd\u662f\u9ed8\u8ba4\u72b6\u6001\uff0c\u8981\u624b\u52a8\u6267\u884c\u4fee\u6539<\/p>\n\n\n\n<p><strong>(4) \u6dfb\u52a0\u547d\u4ee4\u6bcf\u6b21\u542f\u52a8 cmd\/PowerShell \u81ea\u52a8\u6267\u884c\u4fee\u6539\u5b57\u7b26\u7f16\u7801<\/strong><\/p>\n\n\n\n<p>\u2460 \u8bbe\u7f6e cmd \u81ea\u52a8\u6267\u884c<\/p>\n\n\n\n<p>\u6253\u5f00\u5f00\u59cb\u83dc\u5355\u641c\u7d22<strong>\u6ce8\u518c\u8868<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"662\" height=\"547\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-4.png\" alt=\"\" class=\"wp-image-3442 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-4.png 662w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-4-300x248.png 300w\" data-sizes=\"(max-width: 662px) 100vw, 662px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 662px; --smush-placeholder-aspect-ratio: 662\/547;\" \/><\/figure>\n\n\n\n<p>\u6253\u5f00\u8def\u5f84\uff1a <strong>\u8ba1\u7b97\u673a\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Command Processor<\/strong><\/p>\n\n\n\n<p>\u53f3\u952e\u65b0\u5efa<strong>\u5b57\u7b26\u4e32\u503c<\/strong>\uff0c\u547d\u540d\u4e3a <strong>autorun<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"689\" height=\"566\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-5.png\" alt=\"\" class=\"wp-image-3443 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-5.png 689w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-5-300x246.png 300w\" data-sizes=\"(max-width: 689px) 100vw, 689px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 689px; --smush-placeholder-aspect-ratio: 689\/566;\" \/><\/figure>\n\n\n\n<p>\u7136\u540e\u53cc\u51fb\u8bbe\u7f6e\u503c <strong>chcp.com 65001<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"580\" height=\"373\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-6.png\" alt=\"\" class=\"wp-image-3444 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-6.png 580w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-6-300x193.png 300w\" data-sizes=\"(max-width: 580px) 100vw, 580px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 580px; --smush-placeholder-aspect-ratio: 580\/373;\" \/><\/figure>\n\n\n\n<p>\u6253\u5f00\u4e00\u4e2a cmd \u7a97\u53e3\uff0c\u53ef\u4ee5\u770b\u5230\u81ea\u52a8\u6267\u884c\u4e86\u5b57\u7b26\u7f16\u7801\u5207\u6362<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"246\" height=\"97\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/03\/image-9.png\" alt=\"\" class=\"wp-image-3447 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 246px; --smush-placeholder-aspect-ratio: 246\/97;\" \/><\/figure>\n\n\n\n<p>\u2461 \u8bbe\u7f6e PowerShell \u81ea\u52a8\u5207\u6362\u5b57\u7b26\u96c6<\/p>\n\n\n\n<p>\u6253\u5f00 PowerShell \u8f93\u5165 <strong>$PROFILE<\/strong> \u56de\u8f66\uff0c\u53ef\u4ee5\u770b\u5230 PowerShell \u7684\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff0cPowerShell \u5728\u542f\u52a8\u7684\u65f6\u5019\u4f1a\u81ea\u52a8\u6267\u884c\u3002\u8fd9\u4e2a\u8def\u5f84\u53ef\u80fd\u4e0d\u5b58\u5728\uff0c\u4e2d\u95f4\u7f3a\u5c11\u7684\u8981\u81ea\u5df1\u521b\u5efa\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"636\" height=\"58\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2023\/08\/image-1.png\" alt=\"\" class=\"wp-image-10760 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2023\/08\/image-1.png 636w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2023\/08\/image-1-300x27.png 300w\" data-sizes=\"(max-width: 636px) 100vw, 636px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 636px; --smush-placeholder-aspect-ratio: 636\/58;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"642\" height=\"145\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2023\/08\/image-2.png\" alt=\"\" class=\"wp-image-10761 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2023\/08\/image-2.png 642w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2023\/08\/image-2-300x68.png 300w\" data-sizes=\"(max-width: 642px) 100vw, 642px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 642px; --smush-placeholder-aspect-ratio: 642\/145;\" \/><\/figure>\n\n\n\n<p>\u521b\u5efa\u597d\u914d\u7f6e\u6587\u4ef6\u540e\u5411\u91cc\u9762\u5199\u5165<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chcp 65001<\/pre>\n\n\n\n<p>\u53e6\u5916 Windows \u9ed8\u8ba4\u662f\u7981\u6b62 PowerShell \u811a\u672c\u6267\u884c\u7684\uff0c\u4fee\u6539\u6267\u884c\u7b56\u7565\u53c2\u8003\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/blog.iyatt.com\/?p=10735\" target=\"_blank\">https:\/\/blog.iyatt.com\/?p=10735<\/a><\/p>\n\n\n\n<p>\u6700\u540e\u5c31\u53ef\u4ee5\u5b9e\u73b0\u6253\u5f00 PowerShell \u5c31\u662f UTF-8<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2023\/08\/image-3.png\" alt=\"\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 323px; --smush-placeholder-aspect-ratio: 323\/94;\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u5bf9\u4e8e\u7ecf\u5e38\u5728 Linux \u4e0b\u5199\u4ee3\u7801\u7684\u4eba\u6765\u8bf4\uff0c\u4e00\u822c\u800c\u8a00\u5b57\u7b26\u7f16\u7801\u90fd\u662f\u8bbe\u7f6e\u7684 UTF-8\uff0c\u5e94\u8be5\u8bf4\u5f88\u591a\u4ee3\u7801\u7f16\u8f91\u5668\u9ed8\u8ba4\u7684\u5b57 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-3437","post","type-post","status-publish","format-standard","hentry","category-all"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/3437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3437"}],"version-history":[{"count":0,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/3437\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}