{"id":14017,"date":"2024-02-21T09:57:51","date_gmt":"2024-02-21T01:57:51","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=14017"},"modified":"2024-05-05T12:30:39","modified_gmt":"2024-05-05T04:30:39","slug":"windows-%e4%b8%ad%e6%96%87%e7%89%88%e4%b8%8b-msvc-%e5%af%b9-utf-8-%e6%94%af%e6%8c%81","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=14017","title":{"rendered":"Windows \u4e2d\u6587\u7248\u4e0b MSVC \u5bf9 UTF-8 \u652f\u6301\uff08\u907f\u514d\u4e71\u7801\uff09"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.iyatt.com\/?p=14017\/#1_%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83\" >1 \u6d4b\u8bd5\u73af\u5883<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.iyatt.com\/?p=14017\/#2_%E4%B8%AD%E6%96%87%E4%B9%B1%E7%A0%81%E5%87%BA%E7%8E%B0%E7%9A%84%E5%8E%9F%E5%9B%A0\" >2 \u4e2d\u6587\u4e71\u7801\u51fa\u73b0\u7684\u539f\u56e0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.iyatt.com\/?p=14017\/#3_UTF-8_%E6%BA%90%E7%A0%81%E6%89%A7%E8%A1%8C%E4%B9%B1%E7%A0%81%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\" >3 UTF-8 \u6e90\u7801\u6267\u884c\u4e71\u7801\u7684\u89e3\u51b3\u65b9\u6848<\/a><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"1_%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83\"><\/span>1 \u6d4b\u8bd5\u73af\u5883<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u6211\u8fd9\u91cc\u5728<\/p>\n<ul>\n<li>Windows 11 \u4e13\u4e1a\u7248 23H2 \u4e2d\u6587\u7248<\/li>\n<li>PowerShell 7.4.1<br \/>\n\u4e2d\uff0c\u9ed8\u8ba4\u7684\u5b57\u7b26\u7f16\u7801\u662f 936 GB2312<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/02\/image-1708478297775.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 310px; --smush-placeholder-aspect-ratio: 310\/136;\" \/><\/li>\n<\/ul>\n<p>\u5b98\u65b9\u7684\u6807\u8bc6\u7801\u89e3\u91ca\uff1a<a href=\"https:\/\/learn.microsoft.com\/zh-cn\/windows\/win32\/Intl\/code-page-identifiers\">https:\/\/learn.microsoft.com\/zh-cn\/windows\/win32\/Intl\/code-page-identifiers<\/a><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/02\/image-1708478348565.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 768px; --smush-placeholder-aspect-ratio: 768\/194;\" \/><\/p>\n<ul>\n<li>Visual Studio 2022<\/li>\n<\/ul>\n<h1><span class=\"ez-toc-section\" id=\"2_%E4%B8%AD%E6%96%87%E4%B9%B1%E7%A0%81%E5%87%BA%E7%8E%B0%E7%9A%84%E5%8E%9F%E5%9B%A0\"><\/span>2 \u4e2d\u6587\u4e71\u7801\u51fa\u73b0\u7684\u539f\u56e0<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u51fa\u73b0\u4e71\u7801\u901a\u5e38\u5c31\u662f\u8bb0\u5f55\u7684\u89c4\u5219\u548c\u9605\u8bfb\u7684\u89c4\u5219\u4e0d\u4e00\u6837\u5bfc\u81f4\u7684\uff0c\u4e3e\u4e00\u4e2a\u4f8b\u5b50\uff0c\u6211\u5728\u7eb8\u4e0a\u5199\u4e86\u56db\u4e2a\u5b57\u201c\u5973\u5b50\u5f13\u867d\u201d\uff0c\u5982\u679c\u522b\u4eba\u8bfb\u7684\u65f6\u5019\u662f\u628a\u6211\u7684\u6bcf\u4e24\u4e2a\u5b57\u5f53\u4f5c\u4e00\u4e2a\u5b57\uff0c\u90a3\u4e48\u8bfb\u53d6\u51fa\u6765\u5c31\u662f\u201c\u597d\u5f3a\u201d\uff0c\u4e71\u7801\u4ea7\u751f\u5927\u81f4\u5c31\u662f\u76f8\u4f3c\u7684\u539f\u56e0\u3002\u89e3\u51b3\u4e71\u7801\u7684\u95ee\u9898\u5c31\u5728\u4e8e\u4fdd\u8bc1\u6bcf\u4e2a\u9636\u6bb5\u90fd\u662f\u7528\u7684\u5339\u914d\u7684\u89c4\u5219\u3002<\/p>\n<h1><span class=\"ez-toc-section\" id=\"3_UTF-8_%E6%BA%90%E7%A0%81%E6%89%A7%E8%A1%8C%E4%B9%B1%E7%A0%81%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\"><\/span>3 UTF-8 \u6e90\u7801\u6267\u884c\u4e71\u7801\u7684\u89e3\u51b3\u65b9\u6848<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\u5728 Linux \u4e2d\u53ca\u5176\u5b83\u5f88\u591a\u9886\u57df\u7684\u5f00\u53d1\u4e2d UTF-8 \u7f16\u7801\u57fa\u672c\u6210\u4e3a\u89c4\u8303\uff0c\u5728 Windows \u4e2d\u5219\u53ef\u80fd\u51fa\u73b0\u95ee\u9898\u3002\u4e0a\u9762\u4e5f\u63d0\u5230\u4e86\uff0c\u4e2d\u6587\u7248\u7684\u7ec8\u7aef\u7f16\u7801\u662f GB2312\uff0c\u5728\u4fdd\u8bc1\u6e90\u7801\u662f UTF-8 \u7684\u60c5\u51b5\u4e0b\uff0c\u53c8\u8981\u4fdd\u8bc1\u7ec8\u7aef\u6b63\u5e38\u663e\u793a\u4e2d\u6587\uff0c\u8003\u8651\u5230\u4e24\u7c7b\u65b9\u6cd5\uff1a\u4e00\u79cd\u662f\u5c06\u7ec8\u7aef\u7f16\u7801\u6539 UTF-8\uff0c\u53c2\u8003 <a href=\"https:\/\/blog.iyatt.com\/?p=3437\">https:\/\/blog.iyatt.com\/?p=3437<\/a> \uff1b\u7b2c\u4e8c\u79cd\u662f\u8ba9\u7f16\u8bd1\u5668\u6765\u9002\u5e94\u3002<br \/>\n\u7b2c\u4e00\u79cd\u65b9\u5f0f\uff0c\u5f53\u524d\u6211\u662f\u9047\u5230\u4e86\u95ee\u9898\uff08\u524d\u4e24\u5e74\u7528\u7684\u65f6\u5019\u4e0d\u8bb0\u5f97\u6709\u8fd9\u4e2a\u95ee\u9898\uff09\u3002\u6e90\u7801\u91c7\u7528 UTF-8\uff0cMSVC \u7f16\u8bd1\u53c2\u6570\u52a0\u6216\u8005\u4e0d\u52a0 <strong>\/utf-8<\/strong>\uff0c\u7ec8\u7aef\u4e0d\u7ba1\u662f GB2312 \u8fd8\u662f UTF-8\uff0c\u4e2d\u6587\u90fd\u51fa\u73b0\u4e71\u7801\uff0c\u4f46\u662f\u5982\u679c\u6e90\u7801\u91c7\u7528 UTF-8 Bom \u53c8\u6ca1\u6709\u95ee\u9898\uff0c\u90fd\u80fd\u6b63\u5e38\u663e\u793a\u3002<br \/>\n\u7b2c\u4e8c\u79cd\u65b9\u5f0f\uff0c\u8ba9 MSVC \u6309\u7167 UTF-8 \u6765\u5904\u7406\u6e90\u7801\uff0c\u4f46\u662f\u6267\u884c\u7684\u65f6\u5019\u6309\u7167 GB2312\uff0c\u8fd9\u6837\u5c31\u4e0d\u4f1a\u51fa\u73b0\u4e71\u7801\u4e86\u3002\u7ed9 MSVC \u52a0\u4e0a\u7f16\u8bd1\u53c2\u6570<\/p>\n<pre><code>\/source-charset:utf-8 \/execution-charset:gb2312<\/code><\/pre>\n<p>\u57fa\u4e8e VS \u7ba1\u7406\u7684\u9879\u76ee\u7684\u8bdd\uff0c\u5728\u9879\u76ee\u540d\u4e0a\u53f3\u952e\u6253\u5f00\u5c5e\u6027\uff0cC\/C++ -&gt; \u547d\u4ee4\u884c -&gt; \u5176\u4ed6\u9009\u9879 \u4e2d\u52a0\u4e0a<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/02\/image-1708480506484.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 770px; --smush-placeholder-aspect-ratio: 770\/545;\" \/><\/p>\n<p>\u57fa\u4e8e CMake \u7ba1\u7406\u7684\u9879\u76ee\u7684\u8bdd\uff0c\u7528 add_compile_options \u6dfb\u52a0\u7f16\u8bd1\u53c2\u6570\u5c31\u884c<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/02\/image-1708480596525.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 670px; --smush-placeholder-aspect-ratio: 670\/96;\" \/><\/p>\n<p>\u524d\u9762\u63d0\u5230\u7684 <strong>\/utf-8<\/strong> \u5c31\u76f8\u5f53\u4e8e\u662f <strong>\/source-charset:utf-8 \/execution-charset:utf-8<\/strong><\/p>\n<hr \/>\n<p>\u7528 VScode \u7684\u65f6\u5019\u9ed8\u8ba4\u7f16\u7801\u5c31\u662f UTF-8\uff0c\u4fee\u6539\u4e5f\u5341\u5206\u65b9\u4fbf\uff0c\u4f46\u662f\u8c03\u8bd5\u8fd8\u5f97\u662f VS \u5f3a\u5927\uff0c\u5fc5\u4e0d\u53ef\u5c11\u7684\u4f7f\u7528 VS\uff0c\u800c VS \u7684\u7f16\u7801\u81ea\u52a8\u9002\u5e94\u63a7\u5236\u53f0\uff0c\u624b\u52a8\u6307\u5b9a\u4f1a\u6bd4\u8f83\u9ebb\u70e6\u3002<br \/>\n\u53ef\u4ee5\u6dfb\u52a0<strong>\u5f3a\u5236 UTF-8 \u4fdd\u5b58<\/strong>\u7684\u63d2\u4ef6 <strong>Force UTF-8 (No BOM)<\/strong><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/02\/image-1708480308888.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 306px; --smush-placeholder-aspect-ratio: 306\/114;\" \/><\/p>\n<p><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/02\/image-1708480366648.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 434px; --smush-placeholder-aspect-ratio: 434\/133;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1 \u6d4b\u8bd5\u73af\u5883 \u6211\u8fd9\u91cc\u5728 Windows 11 \u4e13\u4e1a\u7248 23H2 \u4e2d\u6587\u7248 PowerShell 7.4.1 \u4e2d\uff0c [&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":"no","_lmt_disable":"no","footnotes":""},"categories":[1],"tags":[],"class_list":["post-14017","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\/14017","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=14017"}],"version-history":[{"count":0,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/14017\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}