{"id":382,"date":"2024-05-07T11:49:24","date_gmt":"2024-05-07T03:49:24","guid":{"rendered":"https:\/\/feel.name\/?p=382"},"modified":"2024-05-07T12:46:33","modified_gmt":"2024-05-07T04:46:33","slug":"linux%e4%b8%8b%e8%bd%ac%e6%8d%a2%e6%96%87%e4%bb%b6%e7%bc%96%e7%a0%81","status":"publish","type":"post","link":"http:\/\/feel.name\/?p=382","title":{"rendered":"Linux\u4e0b\u8f6c\u6362\u6587\u4ef6\u7f16\u7801"},"content":{"rendered":"\n<p>\u6709\u7684\u65f6\u5019\u67e5\u770b\u6587\u4ef6\u683c\u5f0f\u7684\u65f6\u5019\u4f1a\u53d1\u73b0\u6709\u8da3\u7684\u4e8b\u60c5<\/p>\n\n\n\n<p>[root@feel ~]# file system.cfg<br>system.cfg: Non-ISO extended-ASCII text, with CRLF, NEL line terminators<\/p>\n\n\n\n<p>with CRLF, NEL line terminators\u53ef\u4ee5\u5224\u65ad\u662fwindwos\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>linux\u6587\u672c\u683c\u5f0f\u4e3a\uff1aASCII text<\/p>\n\n\n\n<p>windows\u6587\u672c\u683c\u5f0f\u4e3a\uff1aASCII text\uff0cwith CRLF line terminators<\/p>\n\n\n\n<p>\u901a\u8fc7cat -v \u6587\u4ef6\u540d\u547d\u4ee4\u67e5\u770b\u6587\u672c\u5185\u5bb9\uff0c\u884c\u5c3e\u6709^M\u7b26\u53f7<\/p>\n\n\n\n<p>yum install dos2unix -y<\/p>\n\n\n\n<p>dos2unix system.cfg<\/p>\n\n\n\n<p>\u53ef\u4ee5\u53d8\u66f4\u4e3aASCII text<\/p>\n\n\n\n<p>\u901a\u8fc7enca\u5224\u65ad\u6587\u4ef6\u7f16\u7801<\/p>\n\n\n\n<p>yum install enca<\/p>\n\n\n\n<p>[root@feel ~]# enca &#8211;list languages<br>belarusian: CP1251 IBM866 ISO-8859-5 KOI8-UNI maccyr IBM855 KOI8-U<br>bulgarian: CP1251 ISO-8859-5 IBM855 maccyr ECMA-113<br>czech: ISO-8859-2 CP1250 IBM852 KEYBCS2 macce KOI-8_CS_2 CORK<br>estonian: ISO-8859-4 CP1257 IBM775 ISO-8859-13 macce baltic<br>croatian: CP1250 ISO-8859-2 IBM852 macce CORK<br>hungarian: ISO-8859-2 CP1250 IBM852 macce CORK<br>lithuanian: CP1257 ISO-8859-4 IBM775 ISO-8859-13 macce baltic<br>latvian: CP1257 ISO-8859-4 IBM775 ISO-8859-13 macce baltic<br>polish: ISO-8859-2 CP1250 IBM852 macce ISO-8859-13 ISO-8859-16 baltic CORK<br>russian: KOI8-R CP1251 ISO-8859-5 IBM866 maccyr<br>slovak: CP1250 ISO-8859-2 IBM852 KEYBCS2 macce KOI-8_CS_2 CORK<br>slovene: ISO-8859-2 CP1250 IBM852 macce CORK<br>ukrainian: CP1251 IBM855 ISO-8859-5 CP1125 KOI8-U maccyr<br>chinese: GBK BIG5 HZ<br>none:<\/p>\n\n\n\n<p>[root@feel ~]# enca -L chinese system.cfg<br>Unrecognized encoding<\/p>\n\n\n\n<p>enca\u4f1a\u663e\u793a\u662f\u7f16\u7801<\/p>\n\n\n\n<p>[root@feel ~]# enca -L czech system.cfg<br>Kamenicky encoding; KEYBCS2<\/p>\n\n\n\n<p>iconv &#8211;list \u67e5\u770biconv\u652f\u6301\u7684\u7f16\u7801<\/p>\n\n\n\n<p>\u53ef\u4ee5\u5199\u4e2a\u811a\u672c\u4e00\u4e2a\u4e00\u4e2a\u6d4b\u8bd5\u7f16\u7801<\/p>\n\n\n\n<p>\u811a\u672c\u5982\u4e0b<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">#!\/bin\/bash<\/h1>\n\n\n\n<p>iconv &#8211;list | sed &#8216;s\/\\\/\\\/$\/\/&#8217; | sort > encodings.list<br>for a in <code>cat encodings.list<\/code>; do<br>printf &#8220;$a &#8220;<br>iconv -f $a -t UTF-8 system.cfg > \/dev\/null 2>&amp;1 &amp;&amp; echo &#8220;ok: $a&#8221; || echo &#8220;fail: $a&#8221;<br>done | tee result.txt<\/p>\n\n\n\n<p>\u8dd1\u811a\u672c\u540e\u67e5\u770bresult.txt\u91cc\u7684ok  \u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n\n\n\n<p>\u8fd9\u6837\u5c31\u80fd\u8f6c\u6362\u597d\u6587\u4ef6\u7f16\u7801\u4e86\u3002<\/p>\n\n\n\n<p>iconv -f \u6e90\u7f16\u7801 -t UTF-8 \u8f6c\u6362\u524d\u6587\u4ef6\u540d &gt; \u8f6c\u6362\u540e\u6587\u4ef6\u540d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u7684\u65f6\u5019\u67e5\u770b\u6587\u4ef6\u683c\u5f0f\u7684\u65f6\u5019\u4f1a\u53d1\u73b0\u6709\u8da3\u7684\u4e8b\u60c5 [root@feel ~]# file system.cfgsys&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-382","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=382"}],"version-history":[{"count":2,"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions"}],"predecessor-version":[{"id":384,"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions\/384"}],"wp:attachment":[{"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}