{"id":83784,"date":"2024-03-29T10:31:22","date_gmt":"2024-03-29T02:31:22","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=83784"},"modified":"2024-03-29T10:31:22","modified_gmt":"2024-03-29T02:31:22","slug":"linux%e5%a6%82%e4%bd%95%e5%a4%84%e7%90%86%e6%96%87%e4%bb%b6%e7%bc%96%e7%a0%81%e5%92%8c%e8%bd%ac%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/83784.html","title":{"rendered":"Linux\u5982\u4f55\u5904\u7406\u6587\u4ef6\u7f16\u7801\u548c\u8f6c\u6362"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/03\/uploading_images2024-03-19_16-13-46_8087.png?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"Linux\u5982\u4f55\u5904\u7406\u6587\u4ef6\u7f16\u7801\u548c\u8f6c\u6362\" \/><\/p>\n<p>Linux\u5904\u7406\u6587\u4ef6\u7f16\u7801\u548c\u8f6c\u6362\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528<strong>\u6587\u672c\u7f16\u8f91\u5668\u3001\u547d\u4ee4\u884c\u5de5\u5177\u3001\u7f16\u7a0b\u811a\u672c<\/strong>\u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u8bc6\u522b\u548c\u4fee\u6539\u6587\u4ef6\u7684\u5b57\u7b26\u7f16\u7801\uff0c\u786e\u4fdd\u6587\u672c\u6587\u4ef6\u5728\u4e0d\u540c\u7cfb\u7edf\u548c\u7a0b\u5e8f\u95f4\u6b63\u786e\u663e\u793a\u548c\u5904\u7406\u3002\u5176\u4e2d\uff0c\u547d\u4ee4\u884c\u5de5\u5177`iconv`\u5728\u8fd9\u4e00\u8fc7\u7a0b\u4e2d\u5c24\u4e3a\u91cd\u8981\uff0c\u5b83\u53ef\u4ee5\u5b9e\u73b0\u6587\u4ef6\u7f16\u7801\u7684\u8f6c\u6362\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7801\u7c7b\u578b\u3002<\/p>\n<p>\u5c55\u5f00\u8be6\u7ec6\u63cf\u8ff0\uff1a`iconv`\u5de5\u5177\u662fLinux\u73af\u5883\u4e0b\u5e38\u7528\u7684\u5b57\u7b26\u96c6\u8f6c\u6362\u7a0b\u5e8f\uff0c\u5b83\u652f\u6301\u5404\u79cd\u7f16\u7801\u4e4b\u95f4\u7684\u8f6c\u6362\uff0c\u6bd4\u5982\u4eceUTF-8\u8f6c\u6362\u5230ISO-8859-1\u7b49\u3002\u4f7f\u7528`iconv`\u5de5\u5177\u65f6\uff0c\u7528\u6237\u9700\u8981\u6307\u5b9a\u6e90\u7f16\u7801\u548c\u76ee\u6807\u7f16\u7801\uff0c\u8fd8\u53ef\u4ee5\u5229\u7528\u5176\u4ed6\u53c2\u6570\u5982`-c`\u6765\u5ffd\u7565\u8f6c\u6362\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u7684\u9519\u8bef\u5b57\u7b26\uff0c\u6216\u662f\u4f7f\u7528`-o`\u6307\u5b9a\u8f93\u51fa\u6587\u4ef6\u3002\u7531\u4e8e`iconv`\u662f\u57fa\u4e8e\u547d\u4ee4\u884c\u7684\uff0c\u5b83\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u88ab\u96c6\u6210\u5230Shell\u811a\u672c\u6216\u5176\u4ed6\u81ea\u52a8\u5316\u6d41\u7a0b\u4e2d\uff0c\u4ee5\u8fbe\u5230\u6279\u91cf\u5904\u7406\u6587\u4ef6\u7684\u76ee\u7684\u3002<\/p>\n<h2><strong>\u4e00\u3001\u4e86\u89e3\u5b57\u7b26\u7f16\u7801<\/strong><\/h2>\n<p>\u5b57\u7b26\u7f16\u7801\u662f\u6307\u5c06\u5b57\u7b26\u96c6\u5408\u4e2d\u7684\u5b57\u7b26\u7f16\u6392\u6210\u4e00\u5b9a\u987a\u5e8f\uff0c\u5e76\u4e3a\u6bcf\u4e00\u4e2a\u5b57\u7b26\u5206\u914d\u4e00\u4e2a\u7f16\u53f7\u3002\u4e3a\u4e86\u4f7f\u6587\u672c\u4fe1\u606f\u5728\u5b58\u50a8\u548c\u4f20\u8f93\u65f6\u4fdd\u6301\u5176\u542b\u4e49\u4e0d\u88ab\u6539\u53d8\uff0c\u5b57\u7b26\u7f16\u7801\u8d77\u5230\u4e86\u81f3\u5173\u91cd\u8981\u7684\u4f5c\u7528\u3002\u5b57\u7b26\u7f16\u7801\u4e0d\u517c\u5bb9\u4f1a\u5bfc\u81f4\u4e71\u7801\u95ee\u9898\uff0c\u56e0\u6b64\u6b63\u786e\u5904\u7406\u5b57\u7b26\u7f16\u7801\u662f\u4efb\u4f55\u6587\u672c\u5904\u7406\u7684\u57fa\u7840\u3002<\/p>\n<p>&#8211; <strong>\u5b57\u7b26\u7f16\u7801\u57fa\u7840<\/strong><\/p>\n<p>  \u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u5e38\u89c1\u7684\u5b57\u7b26\u7f16\u7801\u5305\u62ecASCII\u3001ISO-8859-1\u3001UTF-8\u3001UTF-16\u7b49\uff0c\u6bcf\u79cd\u7f16\u7801\u90fd\u6709\u81ea\u5df1\u7684\u7279\u70b9\u548c\u5e94\u7528\u573a\u666f\u3002\u4f8b\u5982\uff0cASCII\u7f16\u7801\u4e3b\u8981\u9488\u5bf9\u82f1\u6587\u5b57\u7b26\uff0c\u5360\u75281\u4e2a\u5b57\u8282\uff1b\u800cUTF-8\u662f\u5bf9Unicode\u5b57\u7b26\u96c6\u7684\u53ef\u53d8\u957f\u7f16\u7801\u65b9\u5f0f\uff0c\u53ef\u540c\u65f6\u652f\u6301\u4e16\u754c\u4e0a\u5927\u591a\u6570\u8bed\u8a00\u5b57\u7b26\uff0c\u4e14\u4e0eASCII\u517c\u5bb9\u3002<\/p>\n<p>&#8211; <strong>\u5b57\u7b26\u7f16\u7801\u7684\u91cd\u8981\u6027<\/strong><\/p>\n<p>  \u5728\u5168\u7403\u5316\u7684\u73af\u5883\u4e0b\uff0c\u5904\u7406\u4e0d\u540c\u8bed\u8a00\u7684\u6587\u672c\u65f6\uff0c\u6b63\u786e\u7684\u5b57\u7b26\u7f16\u7801\u5c24\u4e3a\u91cd\u8981\u3002\u6bd4\u5982\uff0c\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5728\u4e0d\u540c\u8bed\u8a00\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e4b\u95f4\u4f20\u9012\u65f6\uff0c\u53ef\u80fd\u4f1a\u56e0\u4e3a\u7f16\u7801\u7684\u4e0d\u4e00\u81f4\u800c\u663e\u793a\u4e3a\u4e71\u7801\u3002\u56e0\u6b64\uff0c\u4e86\u89e3\u5e76\u80fd\u719f\u7ec3\u8f6c\u6362\u5b57\u7b26\u7f16\u7801\uff0c\u5728\u5904\u7406\u8de8\u8bed\u8a00\u3001\u8de8\u5e73\u53f0\u6587\u672c\u6587\u4ef6\u65f6\u663e\u5f97\u5c24\u4e3a\u5173\u952e\u3002<\/p>\n<h2><strong>\u4e8c\u3001\u4f7f\u7528\u56fe\u5f62\u754c\u9762\u5de5\u5177\u5904\u7406\u7f16\u7801<\/strong><\/h2>\n<p>\u5728Linux\u73af\u5883\u4e0b\uff0c\u8bb8\u591a\u56fe\u5f62\u754c\u9762\u6587\u672c\u7f16\u8f91\u5668\uff0c\u5982<strong>Gedit\u3001Kate<\/strong>\u7b49\uff0c\u90fd\u63d0\u4f9b\u5b57\u7b26\u7f16\u7801\u8f6c\u6362\u7684\u529f\u80fd\u3002\u7528\u6237\u53ef\u4ee5\u5728\u8fd9\u4e9b\u7f16\u8f91\u5668\u7684\u754c\u9762\u4e0a\u76f4\u89c2\u5730\u9009\u62e9\u6216\u4fee\u6539\u6587\u4ef6\u7684\u7f16\u7801\uff0c\u64cd\u4f5c\u76f8\u5bf9\u76f4\u89c2\u7b80\u5355\u3002<\/p>\n<p>&#8211; <strong>Gedit\u7684\u7f16\u7801\u8f6c\u6362<\/strong><\/p>\n<p>  Gedit\u662fGnome\u684c\u9762\u73af\u5883\u4e0b\u7684\u9ed8\u8ba4\u6587\u672c\u7f16\u8f91\u5668\u3002\u7528\u6237\u53ef\u4ee5\u5728\u6253\u5f00\u6587\u4ef6\u65f6\u9009\u62e9\u201c\u5b57\u7b26\u7f16\u7801\u201d\uff0c\u5bf9\u6587\u4ef6\u4ee5\u4e0d\u540c\u7684\u7f16\u7801\u8fdb\u884c\u6253\u5f00\u548c\u4fdd\u5b58\u3002Gedit\u8fd8\u652f\u6301\u65b0\u5efa\u6587\u4ef6\u65f6\u9009\u62e9\u7f16\u7801\u683c\u5f0f\uff0c\u975e\u5e38\u9002\u5408\u57fa\u672c\u7684\u7f16\u7801\u8f6c\u6362\u9700\u7528\u3002<\/p>\n<p>&#8211; <strong>Kate\u7684\u7f16\u7801\u529f\u80fd<\/strong><\/p>\n<p>  Kate\u662fKDE\u73af\u5883\u4e0b\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7ea7\u7684\u7f16\u7801\u5904\u7406\u529f\u80fd\u3002\u9664\u4e86\u5728\u6253\u5f00\u548c\u4fdd\u5b58\u6587\u4ef6\u65f6\u9009\u62e9\u7f16\u7801\u5916\uff0cKate\u8fd8\u80fd\u663e\u793a\u5f53\u524d\u6587\u4ef6\u7684\u7f16\u7801\u72b6\u6001\uff0c\u5e76\u5141\u8bb8\u7528\u6237\u901a\u8fc7\u5e95\u90e8\u4fe1\u606f\u680f\u5feb\u901f\u5207\u6362\u7f16\u7801\u3002<\/p>\n<h2><strong>\u4e09\u3001\u5229\u7528\u547d\u4ee4\u884c\u5de5\u5177\u8fdb\u884c\u7f16\u7801\u8f6c\u6362<\/strong><\/h2>\n<p>\u5bf9\u4e8e\u719f\u6089\u547d\u4ee4\u884c\u64cd\u4f5c\u7684\u7528\u6237\u800c\u8a00\uff0cLinux\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u5982<strong>iconv\u3001enca<\/strong>\u7b49\uff0c\u8fd9\u4e9b\u5de5\u5177\u5728\u6587\u4ef6\u7f16\u7801\u8f6c\u6362\u65b9\u9762\uff0c\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u7075\u6d3b\u7684\u4f7f\u7528\u65b9\u5f0f\u3002<\/p>\n<p>&#8211; <strong>\u4f7f\u7528iconv\u8f6c\u6362\u7f16\u7801<\/strong><\/p>\n<p>  `iconv`\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u5de5\u5177\u3002\u901a\u8fc7\u547d\u4ee4`iconv -f <\u6e90\u7f16\u7801> -t <\u76ee\u6807\u7f16\u7801> <\u8f93\u5165\u6587\u4ef6> -o <\u8f93\u51fa\u6587\u4ef6>`\uff0c\u53ef\u5c06\u6587\u4ef6\u4ece\u6e90\u7f16\u7801\u8f6c\u6362\u4e3a\u76ee\u6807\u7f16\u7801\u3002\u7528\u6237\u53ef\u4ee5\u501f\u52a9`iconv`\u547d\u4ee4\u8f7b\u677e\u5b9e\u73b0\u6587\u4ef6\u7f16\u7801\u7684\u8f6c\u6362\uff0c\u81ea\u52a8\u5316\u5730\u5904\u7406\u7f16\u7801\u95ee\u9898\u3002<\/p>\n<p>&#8211; <strong>\u5e94\u7528enca\u81ea\u52a8\u8bc6\u522b\u7f16\u7801<\/strong><\/p>\n<p>  `enca`\uff08Extremely N<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ve Charset Analyser\uff09\u662f\u53e6\u4e00\u4e2a\u7f16\u7801\u5904\u7406\u5de5\u5177\uff0c\u5c24\u5176\u64c5\u957f\u4e8e\u4e1c\u6b27\u8bed\u8a00\u7684\u7f16\u7801\u8bc6\u522b\u548c\u8f6c\u6362\u3002\u8fd0\u884c`enca filename`\u53ef\u4ee5\u83b7\u5f97\u4e00\u4e2a\u5173\u4e8e\u6587\u4ef6\u7f16\u7801\u7684\u5efa\u8bae\u3002enca\u901a\u5e38\u539f\u4e3b\u8981\u7528\u4e8e\u60c5\u51b5\u4e0d\u751a\u660e\u4e86\u65f6\u7684\u81ea\u52a8\u7f16\u7801\u8bc6\u522b\u548c\u8f6c\u6362\u3002<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u5728Linux\u7cfb\u7edf\u4e2d\u67e5\u770b\u6587\u4ef6\u7684\u7f16\u7801\u683c\u5f0f\uff1f<\/strong><\/p>\n<p>\u8981\u67e5\u770b\u6587\u4ef6\u7684\u7f16\u7801\u683c\u5f0f\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u5982file\u6216enca\u3002\u7b80\u5355\u8f93\u5165\u547d\u4ee4&#8221;file \u6587\u4ef6\u540d&#8221;\uff0c\u7cfb\u7edf\u4f1a\u663e\u793a\u6587\u4ef6\u7684\u7f16\u7801\u683c\u5f0f\u4fe1\u606f\uff1b\u6216\u8005\u901a\u8fc7&#8221;enca -L zh_CN \u6587\u4ef6\u540d&#8221;\u67e5\u770b\u5177\u4f53\u7f16\u7801\u4fe1\u606f\u3002<\/p>\n<p><strong>2. \u5728Linux\u7cfb\u7edf\u4e2d\u5982\u4f55\u5c06\u6587\u4ef6\u4ece\u4e00\u79cd\u7f16\u7801\u683c\u5f0f\u8f6c\u6362\u4e3a\u53e6\u4e00\u79cd\uff1f<\/strong><\/p>\n<p>\u8981\u5728Linux\u7cfb\u7edf\u4e2d\u8fdb\u884c\u6587\u4ef6\u7f16\u7801\u683c\u5f0f\u8f6c\u6362\uff0c\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982iconv\u3002\u4f8b\u5982\uff0c\u901a\u8fc7\u547d\u4ee4&#8221;iconv -f utf-8 -t gbk inputFile > outputFile&#8221;\u5c06UTF-8\u7f16\u7801\u7684\u6587\u4ef6\u8f6c\u6362\u4e3aGBK\u7f16\u7801\u7684\u6587\u4ef6\u3002<\/p>\n<p><strong>3. Linux\u7cfb\u7edf\u4e2d\u6709\u54ea\u4e9b\u5e38\u7528\u7684\u6587\u672c\u7f16\u8f91\u5668\u53ef\u4ee5\u5904\u7406\u4e0d\u540c\u7f16\u7801\u7684\u6587\u4ef6\uff1f<\/strong><\/p>\n<p>Linux\u7cfb\u7edf\u4e2d\u6709\u8bb8\u591a\u652f\u6301\u591a\u79cd\u7f16\u7801\u683c\u5f0f\u6587\u4ef6\u7f16\u8f91\u548c\u4fdd\u5b58\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u6bd4\u5982GNU Emacs\u3001Vim\u3001Sublime Text\u7b49\u3002\u8fd9\u4e9b\u7f16\u8f91\u5668\u53ef\u4ee5\u65b9\u4fbf\u5730\u6253\u5f00\u3001\u7f16\u8f91\u548c\u4fdd\u5b58\u5404\u79cd\u7f16\u7801\u683c\u5f0f\u7684\u6587\u4ef6\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u548c\u4fbf\u6377\u7684\u7f16\u8f91\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Linux\u5904\u7406\u6587\u4ef6\u7f16\u7801\u548c\u8f6c\u6362\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u3001\u547d\u4ee4\u884c\u5de5\u5177\u3001\u7f16\u7a0b\u811a\u672c\u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u8bc6\u522b\u548c\u4fee\u6539\u6587\u4ef6\u7684\u5b57\u7b26 [&hellip;]","protected":false},"author":1,"featured_media":83785,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[384],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/83784"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=83784"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/83784\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/83785"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=83784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=83784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=83784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}