{"id":665,"date":"2018-07-30T15:33:02","date_gmt":"2018-07-30T06:33:02","guid":{"rendered":"https:\/\/vongg.com\/?p=665"},"modified":"2018-07-30T18:26:47","modified_gmt":"2018-07-30T09:26:47","slug":"unicode%ef%bc%8cutf8%e6%b7%b1%e5%85%a5%e8%a7%a3%e8%af%b4","status":"publish","type":"post","link":"https:\/\/vongg.com\/?p=665","title":{"rendered":"unicode\uff0cUTF8\u6df1\u5165\u89e3\u8bf4"},"content":{"rendered":"<p><span style=\"color: #ff0000;\">Java\u4e0e\u7f16\u7801\u95ee\u9898\u4e32\u8bb2\u4e4b\u4e8c&#8211;\u5982\u4f55\u7406\u89e3java\u91c7\u7528Unicode\u7f16\u7801<\/span><\/p>\n<p>https:\/\/blog.csdn.net\/shijinupc\/article\/details\/7679945<\/p>\n<p class=\"p15\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">Java<span style=\"font-family: '\u5b8b\u4f53';\">\u5f00\u53d1\u8005\u5fc5\u987b\u7262\u8bb0\uff1a<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u5728<span style=\"font-family: 'Times New Roman';\">Java<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e2d\u5b57\u7b26\u4ec5\u4ee5\u4e00\u79cd\u5f62\u5f0f\u5b58\u5728\uff0c\u90a3\u5c31\u662f<\/span><span style=\"font-family: 'Times New Roman';\">Unicode<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\uff08\u4e0d\u9009\u62e9\u4efb\u4f55\u7279\u5b9a\u7684\u7f16\u7801\uff0c\u76f4\u63a5\u4f7f\u7528\u4ed6\u4eec\u5728\u5b57\u7b26\u96c6\u4e2d\u7684\u7f16\u53f7\uff0c\u8fd9\u662f\u7edf\u4e00\u7684\u552f\u4e00\u65b9\u6cd5\uff09\u3002<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u7531\u4e8e<span style=\"font-family: 'Times New Roman';\">java<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u91c7\u7528<\/span><span style=\"font-family: 'Times New Roman';\">unicode<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7f16\u7801\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">char\u00a0<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5728<\/span><span style=\"font-family: 'Times New Roman';\">java<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e2d\u5360<\/span><span style=\"font-family: 'Times New Roman';\">2<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e2a\u5b57\u8282\u3002<\/span><span style=\"font-family: 'Times New Roman';\">2<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e2a\u5b57\u8282\uff08<\/span><span style=\"font-family: 'Times New Roman';\">16<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4f4d\uff09\u6765\u8868\u793a\u4e00\u4e2a\u5b57\u7b26\u3002<\/span><\/span><\/p>\n<p class=\"p0\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u00a0\u00a0\u00a0 \u8fd9\u91cc\u7684<\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt; font-weight: bold;\">Java<span style=\"font-family: '\u5b8b\u4f53';\">\u4e2d<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u662f\u6307\u5728<span style=\"font-family: 'Times New Roman';\">JVM<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e2d\u3001\u5728\u5185\u5b58\u4e2d\u3001\u5728\u4ee3\u7801\u91cc\u58f0\u660e\u7684\u6bcf\u4e00\u4e2a<\/span><span style=\"font-family: 'Times New Roman';\">char<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u3001<\/span><span style=\"font-family: 'Times New Roman';\">String<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7c7b\u578b\u7684\u53d8\u91cf\u4e2d\u3002<\/span><\/span><\/p>\n<p>public class UnicodeTest {<br \/>\npublic static void main(String[] args) throws UnsupportedEncodingException {<br \/>\nSystem.out.println(System.getProperty(&#8220;file.encoding&#8221;));<br \/>\nchar han = &#8216;\u6c38&#8217;;<br \/>\nSystem.out.format(&#8220;%x&#8221;, (short) han);\/\/ \u5bf9\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff08\u77ed\u6574\u578b\uff09\u683c\u5f0f\u5316\u4e3a\u5341\u516d\u8fdb\u5236\u8f93\u51fa\uff0c0x\u5f00\u5934<br \/>\nSystem.out.println(&#8220;&#8221;);<br \/>\n\/\/ \u8f93\u51fa6c38<br \/>\nchar han1 = 0x6c38;\/\/ 0x5140;\/\/ 16*3+8 + 6*16*16*16 + 12*16*16;\/\/0x6c38;<br \/>\nSystem.out.println(han1);<br \/>\nSystem.out.println((short) han1);<br \/>\nSystem.out.println(&#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8220;);<br \/>\n\/\/ String.getBytes(&#8220;aaa&#8221;);<\/p>\n<p>String str = &#8220;\u6c38&#8221;;<br \/>\nbyte b[] = null;<br \/>\n\/\/ UTF8\u6c49\u5b57\u5360\u4e09\u4e2a\u5b57\u8282<br \/>\nb = str.getBytes(&#8220;UTF-8&#8221;);<br \/>\nSystem.out.println(&#8220;UTF8\u7f16\u7801\u683c\u5f0f\u4e0b\uff0c\u4e00\u4e2a\u6c49\u5b57\u5360&#8221; + b.length + &#8220;\u5b57\u8282: &#8220;);<br \/>\nfor (byte i : b) {<br \/>\nSystem.out.format(&#8220;%x &#8220;, i);<br \/>\n}<br \/>\nSystem.out.println();<br \/>\n\/\/ \u524d\u9762\u591a\u7684\u4e24\u4e2a\u662f\u5b57\u5e8f\u6807\u8bb0<br \/>\nb = str.getBytes(&#8220;UTF-16&#8221;);<br \/>\nSystem.out.println(&#8220;UTF16\u7f16\u7801\u683c\u5f0f\u4e0b\uff0c\u4e00\u4e2a\u6c49\u5b57\u5360&#8221; + (b.length &#8211; 2) + &#8220;\u5b57\u8282: &#8220;);<br \/>\nfor (byte i : b) {<br \/>\nSystem.out.format(&#8220;%x &#8220;, i);<br \/>\n}<br \/>\nSystem.out.println();<br \/>\n\/\/ ANSI\u7801\u5c0f\u4e8e128\u7684\u5b57\u7b26\u5360\u4e00\u4e2a\u5b57\u8282\uff0c\u5176\u4f59\u5360\u4fe9\u5b57\u8282<br \/>\nb = str.getBytes();<br \/>\nSystem.out.println(&#8220;\u9ed8\u8ba4\u7f16\u7801&#8221; + System.getProperty(&#8220;file.encoding&#8221;) + &#8220;\u7f16\u7801\u683c\u5f0f\u4e0b\uff0c\u4e00\u4e2a\u6c49\u5b57\u5360&#8221; + b.length + &#8220;\u5b57\u8282:&#8221;);<br \/>\nfor (byte i : b) {<br \/>\nSystem.out.format(&#8220;%x &#8220;, i);<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p class=\"p15\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ea\u8981\u6211\u4eec\u6b63\u786e\u5730\u8bfb\u5165\u4e86\u6c49\u5b57\u201c\u6c38\u201d\u5b57\uff0c\u90a3\u4e48\u5b83\u5728\u5185\u5b58\u4e2d\u7684\u8868\u793a\u5f62\u5f0f\u4e00\u5b9a\u662f<span style=\"font-family: 'Times New Roman';\">0x6c38<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\uff0c\u6ca1\u6709\u5176\u4ed6\u4efb\u4f55\u503c\u80fd\u66ff\u4ee3\u8fd9\u4e2a\u5b57\u3002<\/span><\/span><\/p>\n<p class=\"p0\"><span style=\"color: #ff00ff;\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">JVM<span style=\"font-family: '\u5b8b\u4f53';\">\u7684\u6298\u4e2d\u7ea6\u5b9a\u4f7f\u5f97\u4e00\u4e2a\u5b57\u7b26\u5206\u4e3a\u4e24\u90e8\u5206\uff1a<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">JVM<span style=\"font-family: '\u5b8b\u4f53';\">\u5185\u90e8\u548c<\/span><span style=\"font-family: 'Times New Roman';\">OS<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7684\u6587\u4ef6\u7cfb\u7edf<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u3002<\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt; font-weight: bold;\">\u5728<span style=\"font-family: 'Times New Roman';\">JVM<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5185\u90e8\uff0c\u7edf\u4e00\u4f7f\u7528<\/span><span style=\"font-family: 'Times New Roman';\">Unicode<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u8868\u793a<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\uff0c\u5f53\u8fd9\u4e2a\u5b57\u7b26\u88ab\u4ece<span style=\"font-family: 'Times New Roman';\">JVM<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5185\u90e8\u79fb\u5230\u5916\u90e8\uff08\u5373\u4fdd\u5b58\u4e3a\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u4e00\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u65f6\uff09\uff0c\u5c31\u8fdb\u884c\u4e86\u7f16\u7801\u8f6c\u6362\uff0c\u4f7f\u7528\u4e86\u5177\u4f53\u7684\u7f16\u7801\u65b9\u6848\u3002\u56e0\u6b64\u53ef\u4ee5\u8bf4\u6240\u6709\u7684\u7f16\u7801\u8f6c\u6362\u53ea\u53d1\u751f\u5728<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt; font-weight: bold;\">\u8fb9\u754c<\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u7684\u5730\u65b9\uff0c<span style=\"font-family: 'Times New Roman';\">JVM<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u548c<\/span><span style=\"font-family: 'Times New Roman';\">OS<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7684\u4ea4\u754c\u5904\uff0c\u4e5f\u5c31\u662f\u5404\u79cd\u8f93\u5165<\/span><span style=\"font-family: 'Times New Roman';\">\/<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u8f93\u51fa\u6d41\uff08\u6216\u8005<\/span><span style=\"font-family: 'Times New Roman';\">Reader<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">Writer<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7c7b\uff09\u8d77\u4f5c\u7528\u7684\u5730\u65b9\u3002<\/span><\/span><\/span><\/p>\n<p class=\"p0\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u6240\u6709\u7684<span style=\"font-family: 'Times New Roman';\">I\/O<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u57fa\u672c\u4e0a\u53ef\u4ee5\u5206\u4e3a\u4e24\u5927\u9635\u8425\uff1a\u9762\u5411\u5b57\u7b26\u7684\u8f93\u5165<\/span><span style=\"font-family: 'Times New Roman';\">\/<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u8f93\u51fa\u6d41\uff1b\u9762\u5411\u5b57\u8282\u7684\u8f93\u5165<\/span><span style=\"font-family: 'Times New Roman';\">\/<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u8f93\u51fa\u6d41\u3002\u8fd9\u4e2a<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt; font-weight: bold;\">\u201c\u9762\u5411\u201d<\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u662f\u6307\u8fd9\u4e9b\u7c7b\u5728\u5904\u7406\u8f93\u5165<span style=\"font-family: 'Times New Roman';\">\/<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u8f93\u51fa\u7684\u65f6\u5019\uff0c\u5728\u54ea\u4e2a\u610f\u4e49\u4e0a\u4fdd\u6301\u4e00\u81f4\u3002<\/span><\/span><\/p>\n<p class=\"p0\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u00a0\u00a0\u00a0 \u5982\u679c\u9762\u5411\u5b57\u8282\uff0c\u90a3\u4e48\u8fd9\u7c7b\u5de5\u4f5c\u8981\u4fdd\u8bc1\u7cfb\u7edf\u4e2d\u7684\u6587\u4ef6\u4e8c\u8fdb\u5236\u5185\u5bb9\u548c\u8bfb\u5165<span style=\"font-family: 'Times New Roman';\">JVM<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5185\u90e8\u7684\u4e8c\u8fdb\u5236\u5185\u5bb9\u4e00\u81f4\uff0c\u4e0d\u80fd\u53d8\u6362\u4efb\u4f55<\/span><span style=\"font-family: 'Times New Roman';\">0<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u548c<\/span><span style=\"font-family: 'Times New Roman';\">1<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7684\u987a\u5e8f\u3002\u8fd9\u79cd\u8f93\u5165<\/span><span style=\"font-family: 'Times New Roman';\">\/<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u8f93\u51fa\u65b9\u5f0f\u5f88\u9002\u5408\u8bf8\u5982\u89c6\u9891\u6587\u4ef6\u6216\u8005\u97f3\u9891\u6587\u4ef6\uff0c\u56e0\u4e3a\u4e0d\u9700\u8981\u53d8\u6362\u4efb\u4f55\u6587\u4ef6\u5185\u5bb9\u3002<\/span><\/span><\/p>\n<p class=\"p0\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u800c\u9762\u5411\u5b57\u7b26\u7684<span style=\"font-family: 'Times New Roman';\">I\/O<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u662f\u6307\u5e0c\u671b\u7cfb\u7edf\u4e2d\u7684\u6587\u4ef6\u7684\u5b57\u7b26\u548c\u8bfb\u5165\u5185\u5b58\u7684\u201c\u5b57\u7b26\u201d\u8981\u4e00\u81f4\u3002\u4f8b\u5982\uff1a\u6211\u4eec\u7684\u4e2d\u6587\u7248<\/span><span style=\"font-family: 'Times New Roman';\">XP<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7cfb\u7edf\u4e0a\u6709\u4e00\u4e2a<\/span><span style=\"font-family: 'Times New Roman';\">GBK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5176\u4e2d\u6709\u4e00\u4e2a\u201c\u6c38\u201d\u5b57\uff0c\u6211\u4eec\u4e0d\u5173\u5fc3\u8fd9\u4e2a\u5b57\u7684<\/span><span style=\"font-family: 'Times New Roman';\">GBK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7f16\u7801\u662f\u4ec0\u4e48\uff0c\u53ea\u5e0c\u671b\u5728\u4f7f\u7528\u9762\u5411\u5b57\u7b26\u7684<\/span><span style=\"font-family: 'Times New Roman';\">I\/O<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u628a\u5b83\u8bfb\u5165\u5185\u5b58\u5e76\u4fdd\u5b58\u5728\u4e00\u4e2a<\/span><span style=\"font-family: 'Times New Roman';\">char<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u578b\u53d8\u91cf\u4e2d\u65f6\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">I\/O<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7cfb\u7edf\u4e0d\u8981\u76f4\u63a5\u628a\u201c\u6c38\u201d\u5b57\u7684<\/span><span style=\"font-family: 'Times New Roman';\">GBK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7f16\u7801\u653e\u5230\u8fd9\u4e2a\u5b57\u7b26\uff08<\/span><span style=\"font-family: 'Times New Roman';\">char<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\uff09\u578b\u53d8\u91cf\u4e2d\uff0c\u6211\u4eec\u4e0d\u5173\u5fc3\u8fd9\u4e2a<\/span><span style=\"font-family: 'Times New Roman';\">char<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u578b\u53d8\u91cf\u5177\u4f53\u7684\u4e8c\u8fdb\u5236\u5185\u5bb9\u5230\u5e95\u662f\u591a\u5c11\uff0c\u53ea\u5e0c\u671b\u8fd9\u4e2a\u5b57\u7b26\u8bfb\u8fdb\u6765\u4e4b\u540e\u4ecd\u7136\u662f\u201c\u6c38\u201d\u5b57\u3002<\/span><\/span><\/p>\n<p class=\"p0\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt; font-weight: bold;\">\u00a0\u00a0 \u4ece\u8fd9\u4e2a\u610f\u4e49\u4e0a\u53ef\u4ee5\u770b\u51fa\uff0c\u9762\u5411\u5b57\u7b26\u7684<span style=\"font-family: 'Times New Roman';\">I\/O<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7c7b\uff0c\u4e5f\u5c31\u662f<\/span><span style=\"font-family: 'Times New Roman';\">Reader<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u548c<\/span><span style=\"font-family: 'Times New Roman';\">Writer<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7c7b\uff0c\u5b9e\u9645\u4e0a\u9690\u5f0f\u505a\u4e86\u7f16\u7801\u8f6c\u6362\uff0c<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u5728\u8f93\u51fa\u65f6\uff0c\u5c06\u5185\u5b58\u4e2d\u7684<span style=\"font-family: 'Times New Roman';\">Unicode<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5b57\u7b26\u4f7f\u7528\u7cfb\u7edf\u9ed8\u8ba4\u7f16\u7801\u65b9\u5f0f\u8fdb\u884c\u4e86\u7f16\u7801\uff0c\u800c\u5728\u8f93\u5165\u65f6\uff0c\u5c06\u6587\u4ef6\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u7f16\u7801\u8fc7\u7684\u5b57\u7b26\u4f7f\u7528\u9ed8\u8ba4\u7f16\u7801\u65b9\u6848\u8fdb\u884c\u4e86\u8fd8\u539f\u3002<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt; font-weight: bold;\">\u8fd9\u91cc\u8981\u6ce8\u610f\uff0c<span style=\"font-family: 'Times New Roman';\">Reader<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u548c<\/span><span style=\"font-family: 'Times New Roman';\">Writer<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u53ea\u4f1a\u4f7f\u7528\u8fd9\u4e2a\u9ed8\u8ba4\u7684\u7f16\u7801\u6765\u505a\u8f6c\u6362\uff0c\u800c\u4e0d\u80fd\u4e3a\u4e00\u4e2a<\/span><span style=\"font-family: 'Times New Roman';\">Reader<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u548c<\/span><span style=\"font-family: 'Times New Roman';\">Writer<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6307\u5b9a\u8f6c\u6362\u65f6\u4f7f\u7528\u7684\u7f16\u7801\u3002<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u8fd9\u4e5f\u610f\u5473\u7740\uff0c\u5982\u679c\u4f7f\u7528\u4e2d\u6587\u7248<span style=\"font-family: 'Times New Roman';\">WindowsXP<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7cfb\u7edf\uff0c\u5176\u4e2d\u5b58\u653e\u4e86\u4e00\u4e2a<\/span><span style=\"font-family: 'Times New Roman';\">UTF8<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7f16\u7801\u7684\u6587\u4ef6\uff0c\u5f53\u91c7\u7528<\/span><span style=\"font-family: 'Times New Roman';\">Reader<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7c7b\u6765\u8bfb\u5165\u7684\u65f6\u5019\uff0c\u5b83\u8fd8\u4f1a\u7528<\/span><span style=\"font-family: 'Times New Roman';\">GBK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6765\u8f6c\u6362\uff0c\u8f6c\u6362\u540e\u7684\u5185\u5bb9\u5f53\u7136\u4e0d\u5bf9\u3002\u8fd9\u5176\u5b9e\u662f\u4e00\u79cd\u50bb\u74dc\u5f0f\u7684\u529f\u80fd\u63d0\u4f9b\u65b9\u5f0f\uff0c\u5bf9\u5927\u591a\u6570\u521d\u7ea7\u7528\u6237\uff08\u4ee5\u53ca\u4e0d\u9700\u8981\u8de8\u5e73\u53f0\u7684\u9ad8\u7ea7\u7528\u6237\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">windows<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e00\u822c\u91c7\u7528<\/span><span style=\"font-family: 'Times New Roman';\">GBK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">linux<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e00\u822c\u91c7\u7528<\/span><span style=\"font-family: 'Times New Roman';\">UTF8<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\uff09\u6765\u8bf4\u53cd\u800c\u662f\u4e00\u4ef6\u597d\u4e8b\u3002<\/span><\/span><\/p>\n<p class=\"p0\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u00a0\u00a0\u00a0\u5982\u679c\u7528\u5230<span style=\"font-family: 'Times New Roman';\">GBK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7f16\u7801\u4ee5\u5916\u7684\u6587\u4ef6\uff0c\u5c31\u5fc5\u987b\u91c7\u7528\u7f16\u7801\u8f6c\u6362\uff1a\u4e00\u4e2a\u5b57\u7b26\u4e0e\u5b57\u8282\u4e4b\u95f4\u7684\u8f6c\u6362\u3002<\/span><\/span><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt; font-weight: bold;\">\u56e0\u6b64\uff0c<span style=\"font-family: 'Times New Roman';\">Java<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7684<\/span><span style=\"font-family: 'Times New Roman';\">I\/O<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7cfb\u7edf\u4e2d\u80fd\u591f\u6307\u5b9a\u8f6c\u6362\u7f16\u7801\u7684\u5730\u65b9\uff0c\u4e5f\u5c31\u662f\u5728\u5b57\u7b26\u4e0e\u5b57\u8282\u8f6c\u6362\u7684\u5730\u65b9\uff0c\u90a3\u5c31\u662f<\/span><span style=\"font-family: 'Times New Roman';\">InputStremReader<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e0e<\/span><span style=\"font-family: 'Times New Roman';\">OutputStreamWriter<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u3002\u8fd9\u4e24\u4e2a\u7c7b\u662f\u5b57\u8282\u6d41\u548c\u5b57\u7b26\u6d41\u7684\u9002\u914d\u5668\u7c7b\uff0c\u5b83\u4eec\u627f\u62c5\u7f16\u7801\u8f6c\u6362\u7684\u4efb\u52a1\u3002<\/span><\/span><\/p>\n<p class=\"p15\"><span style=\"font-family: '\u5b8b\u4f53'; font-size: 10.5pt;\">\u65e2\u7136<span style=\"font-family: 'Times New Roman';\">java<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u662f\u7528<\/span><span style=\"font-family: 'Times New Roman';\">unicode<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6765\u7f16\u7801\u5b57\u7b26\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">&#8220;<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6211<\/span><span style=\"font-family: 'Times New Roman';\">&#8220;<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u8fd9\u4e2a\u4e2d\u6587\u5b57\u7b26\u7684<\/span><span style=\"font-family: 'Times New Roman';\">unicode<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5c31\u662f<\/span><span style=\"font-family: 'Times New Roman';\">2<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e2a\u5b57\u8282\u3002<\/span><span style=\"font-family: 'Times New Roman';\">String.getBytes(encoding)<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u65b9\u6cd5\u662f\u83b7\u53d6\u6307\u5b9a\u7f16\u7801\u7684<\/span><span style=\"font-family: 'Times New Roman';\">byte<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6570\u7ec4\u8868\u793a\uff0c\u901a\u5e38<\/span><span style=\"font-family: 'Times New Roman';\">gbk\/gb2312<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u662f<\/span><span style=\"font-family: 'Times New Roman';\">2<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e2a\u5b57\u8282\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">utf-8<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u662f<\/span><span style=\"font-family: 'Times New Roman';\">3<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u4e2a\u5b57\u8282\u3002\u5982\u679c\u4e0d\u6307\u5b9a<\/span><span style=\"font-family: 'Times New Roman';\">encoding<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5219\u53d6\u7cfb\u7edf\u9ed8\u8ba4\u7684<\/span><span style=\"font-family: 'Times New Roman';\">encoding<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u3002<\/span><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><span style=\"font-family: '\u5b8b\u4f53';\">\u7531\u4e8e<\/span><span style=\"font-family: 'Times New Roman';\">JDK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u662f\u56fd\u9645\u7248\u7684\uff0c\u5728\u7f16\u8bd1\u7684\u65f6\u5019\uff0c\u5982\u679c\u6211\u4eec\u6ca1\u6709\u7528<\/span><span style=\"font-family: 'Times New Roman';\">-encoding<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u53c2\u6570\u6307\u5b9a\u6211\u4eec\u7684<\/span><span style=\"font-family: 'Times New Roman';\">JAVA<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6e90\u7a0b\u5e8f\u7684\u7f16\u7801\u683c\u5f0f\uff0c\u5219<\/span><span style=\"font-family: 'Times New Roman';\">javac.exe<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u9996\u5148\u83b7\u5f97\u6211\u4eec\u64cd\u4f5c\u7cfb\u7edf\u9ed8\u8ba4\u91c7\u7528\u7684\u7f16\u7801\u683c\u5f0f\uff0c\u4e5f\u5373\u5728\u7f16\u8bd1<\/span><span style=\"font-family: 'Times New Roman';\">java<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7a0b\u5e8f\u65f6\uff0c\u82e5\u6211\u4eec\u4e0d\u6307\u5b9a\u6e90\u7a0b\u5e8f\u6587\u4ef6\u7684\u7f16\u7801\u683c\u5f0f\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">JDK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u9996\u5148\u83b7\u5f97\u64cd\u4f5c\u7cfb\u7edf\u7684<\/span><span style=\"font-family: 'Times New Roman';\">file.encoding<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u53c2\u6570<\/span><span style=\"font-family: 'Times New Roman';\">(<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5b83\u4fdd\u5b58\u7684\u5c31\u662f\u64cd\u4f5c\u7cfb\u7edf\u9ed8\u8ba4\u7684\u7f16\u7801\u683c\u5f0f\uff0c\u5982<\/span><span style=\"font-family: 'Times New Roman';\">WIN2k<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\uff0c\u5b83\u7684\u503c\u4e3a<\/span><span style=\"font-family: 'Times New Roman';\">GBK)<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\uff0c\u7136\u540e<\/span><span style=\"font-family: 'Times New Roman';\">JDK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5c31\u628a\u6211\u4eec\u7684<\/span><span style=\"font-family: 'Times New Roman';\">java<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6e90\u7a0b\u5e8f\u4ece<\/span><span style=\"font-family: 'Times New Roman';\">file.encoding<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7f16\u7801\u683c\u5f0f\u8f6c\u5316\u4e3a<\/span><span style=\"font-family: 'Times New Roman';\">JAVA<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5185\u90e8\u9ed8\u8ba4\u7684<\/span><span style=\"font-family: 'Times New Roman';\">UNICODE<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u683c\u5f0f\u653e\u5165\u5185\u5b58\u4e2d\u3002\u7136\u540e\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">javac<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u628a\u8f6c\u6362\u540e\u7684<\/span><span style=\"font-family: 'Times New Roman';\">unicode<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u683c\u5f0f\u7684\u6587\u4ef6\u8fdb\u884c\u7f16\u8bd1\u6210<\/span><span style=\"font-family: 'Times New Roman';\">.class<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7c7b\u6587\u4ef6\uff0c\u6b64\u65f6<\/span><span style=\"font-family: 'Times New Roman';\">.class<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6587\u4ef6\u662f<\/span><span style=\"font-family: 'Times New Roman';\">UNICODE<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7f16\u7801\u7684\uff0c\u5b83\u6682\u653e\u5728\u5185\u5b58\u4e2d\uff0c\u7d27\u63a5\u7740\uff0c<\/span><span style=\"font-family: 'Times New Roman';\">JDK<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u5c06\u6b64\u4ee5<\/span><span style=\"font-family: 'Times New Roman';\">UNICODE<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7f16\u7801\u7684\u7f16\u8bd1\u540e\u7684<\/span><span style=\"font-family: 'Times New Roman';\">class<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6587\u4ef6\u4fdd\u5b58\u5230\u6211\u4eec\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u5f62\u6210\u6211\u4eec\u89c1\u5230\u7684<\/span><span style=\"font-family: 'Times New Roman';\">.class<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6587\u4ef6\u3002\u5bf9\u6211\u4eec\u6765\u8bf4\uff0c\u6211\u4eec\u6700\u7ec8\u83b7\u5f97\u7684<\/span><span style=\"font-family: 'Times New Roman';\">.class<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u6587\u4ef6\u662f\u5185\u5bb9\u4ee5<\/span><span style=\"font-family: 'Times New Roman';\">UNICODE<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u7f16\u7801\u683c\u5f0f\u4fdd\u5b58\u7684\u7c7b\u6587\u4ef6\uff0c\u5b83\u5185\u90e8\u5305\u542b\u6211\u4eec\u6e90\u7a0b\u5e8f\u4e2d\u7684\u4e2d\u6587\u5b57\u7b26\u4e32\uff0c\u53ea\u4e0d\u8fc7\u6b64\u65f6\u5b83\u5df1\u7ecf\u7531<\/span><span style=\"font-family: 'Times New Roman';\">file.encoding<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u683c\u5f0f\u8f6c\u5316\u4e3a<\/span><span style=\"font-family: 'Times New Roman';\">UNICODE<\/span><span style=\"font-family: '\u5b8b\u4f53';\">\u683c\u5f0f\u4e86\u3002<\/span><\/span><\/p>\n<p><u><span style=\"color: #0066cc;\">\u8c08\u8c08\u5bf9Java\u4e2dUnicode\u3001\u7f16\u7801\u7684\u7406\u89e3<\/span><\/u><\/p>\n<p>https:\/\/www.cnblogs.com\/newstar\/archive\/2011\/06\/13\/2079870.html<\/p>\n<p>\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u7f16\u7801\u95ee\u9898\u3002Java\u53f7\u79f0\u56fd\u9645\u5316\u7684\u8bed\u8a00\uff0c\u662f\u56e0\u4e3a\u5b83\u7684class\u6587\u4ef6\u91c7\u7528UTF-8\uff0c\u800cJVM\u8fd0\u884c\u65f6\u4f7f\u7528UTF-16\uff08\u81f3\u4e8e\u4e3a\u4ec0\u4e48JVM\u4e2d\u8981\u91c7\u7528UTF-16\uff0c\u6211\u6ca1\u770b\u8fc7 \u76f8\u5173\u7684\u8d44\u6599\uff0c\u4f46\u6211\u731c\u53ef\u80fd\u662f\u56e0\u4e3aJAVA\u91cc\u9762\u4e00\u4e2a\u5b57\u7b26(char)\u5c31\u662f16\u4f4d\u7684\uff0c\u800cUTF-16\u6b63\u662f\u53cc\u5b57\u8282\u7f16\u7801\uff09\uff0c\u90fd\u662funicode\u7684\u7f16\u7801\u3002\u00a0\u00a0\u00a0\u00a0\u00a0unicode \u7684\u76ee\u6807\u5c31\u662f\u80fd\u652f\u6301\u4e16\u754c\u4e0a\u6240\u6709\u7684\u5b57\u7b26\u96c6\uff0c\u4e5f\u5c31\u662f\u8bf4\u51e0\u4e4e\u6240\u6709\u7684\u5b57\u7b26\u96c6\u5305\u542b\u7684\u5b57\u7b26\u5728unicode\u4e2d\u90fd\u6709\u5bf9\u5e94\u7684\u7f16\u7801\u3002\u5728unicode\u4e2d\uff0c\u5b57\u7b26\u4e0e\u4ee3\u7801\u7684\u6620\u5c04\u5173 \u7cfb\uff0c\u5c31\u662funicode\u5b57\u7b26\u96c6\uff0c\u79f0\u4e3aUCS(Unicode Character Set)\uff0c\u6bcf\u4e2aunicode\u5b57\u7b26\u7f16\u7801\u79f0\u4e3acode point\uff08\u4ee3\u7801\u70b9\uff1f\uff09\u3002UTF-8\u548cUTF-16\u662f\u4e0d\u540c\u7684UCS\u7f16\u7801\u65b9\u6cd5\uff0cUTF\u5c31\u662fUCS Transformation Format\u3002;<\/p>\n<p>\u5728Java \u4e2d\uff0cString\u7684getBytes()\u65b9\u6cd5\u5c31\u662f\u5bf9\u7279\u5b9a\u7684\u5b57\u7b26\u4e32(unicode)\u6309\u7167\u7ed9\u5b9a\u7684\u5b57\u7b26\u96c6\u8fdb\u884c\u7f16\u7801\uff08encode\uff09\uff0cnew String()\u5219\u53ef\u4ee5\u6309\u7167\u67d0\u4e2a\u5b57\u7b26\u96c6\u5c06\u5b57\u8282\u6d41\u8f6c\u6362\u56deunicode\uff08decode\uff09\u3002Java\u91cc\u9762\u7684\u6bcf\u4e00\u4e2aString\u90fd\u662funicode\u7f16\u7801\u3002<\/p>\n<p>\u518d\u6765\u770b\u9875\u9762\uff0c\u5982\u679c\u4e0d\u505a\u7279\u6b8a\u5904\u7406\uff0cForm\u7684\u63d0\u4ea4\u5c31\u6309\u7167\u9875\u9762\u7684ContentType\u8bbe\u7f6e\u4e2d\u7684\u5b57\u7b26\u96c6\u8fdb\u884c\u7f16\u7801\u8f6c\u6362\uff0c\u53d1\u9001\u5230\u540e\u53f0\uff0c\u540e\u53f0\u5fc5\u987b\u5229\u7528req.setCharacterEncoding\u6765\u6307\u5b9a\u53c2\u6570\u7684\u7f16\u7801\u683c\u5f0f(\u4e0d\u540c\u7684\u5e94\u7528\u670d\u52a1\u5668\u5e94\u6709\u4e0d\u540c\u7684\u6307\u5b9a\u65b9\u5f0f)\uff0c\u624d\u80fd\u6b63\u786e\u89e3\u7801\u3002<\/p>\n<p>Java \u91cc\u9762\u7684encode\u548cdecode\u90fd\u662f\u76f8\u5bf9\u4e8eunicode\u800c\u8a00\u7684\uff0cencode\u7684\u610f\u601d\u662f\u5c06char[] &#8211;&gt; XXX Encoding byte[]\uff0cdecode\u5c31\u662f\u7531XXX Encoding byte[] &#8211;&gt; char[]\u3002\u5e73\u5e38\uff0c\u5f53\u6211\u4eec\u8bf4\u201c\u5c06GBK\u7f16\u7801\u8f6c\u6362\u4e3aUTF-8\u7f16\u7801\u201d\u7684\u65f6\u5019\uff0c\u5b9e\u9645\u7684\u610f\u601d\u5c31\u662f\uff1aGBK Encoding byte[] &#8211;&gt; UTF-8 Encoding byte[]\uff0c\u8fd9\u79cd\u8f6c\u6362\u53ea\u6709\u5728\u9700\u8981\u7528byte[]\u4f20\u8f93\u6570\u636e\u7684\u65f6\u5019\u624d\u6709\u610f\u4e49\uff0c\u5426\u5219\u4fbf\u662f\u6beb\u65e0\u610f\u4e49\u7684\u3002<\/p>\n<p>\u9996\u5148\u8981\u8bf4\u660e\u7684\u4e00\u70b9\u662f\uff1aJava\u4e2d\u7684String\u5bf9\u8c61\u5c31\u662f\u4e00\u4e2aunicode\u7f16\u7801\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u542c\u5230\u6709\u4eba\u8bf4\uff1a\u201c\u6211\u4eec\u9700\u8981\u5c06String\u7531ISO-8859-1\u8f6c\u6362\u4e3aGBK\u7f16\u7801\u201d\uff0c\u8fd9\u53c8\u662f\u600e\u4e48\u56de\u4e8b\u5462\uff1f\u5b9e\u9645\u4e0a\uff0c\u6211\u4eec\u5e76\u4e0d\u662f\u8981\u201c\u5c06 \u4e00\u4e2a\u7531ISO-8859-1\u7f16\u7801\u7684String\u8f6c\u6362\u4e3aGBK\u7f16\u7801\u7684String\u201d\uff0c\u53cd\u590d\u8bf4\u660e\u7684\u662f\uff0cJAVA\u4e2d\u7684String\u90fd\u662funicode\u7f16\u7801\u7684\uff0c\u6240\u4ee5\u4e0d\u5b58\u5728\u201cISO- 8859-1\u7f16\u7801\u7684String\u201d\u6216\u201cGBK\u7f16\u7801\u7684String\u201d\u8fd9\u6837\u7684\u8bf4\u6cd5\u3002\u800c\u9700\u8981\u8f6c\u6362\u7684\u552f\u4e00\u7684\u539f\u56e0\u662fString\u8fdb\u884c\u4e86\u9519\u8bef\u7684\u7f16\u7801\u3002\u6211\u4eec\u7ecf\u5e38\u4f1a\u78b0\u5230\u7531ISO-8859- 1\u8f6c\u6362\u4e3a\u8bf8\u5982GBK\/UTF-8\u7b49\u7b49\u8fd9\u6837\u7684\u9700\u6c42\u3002\u6240\u8c13\u7684\u8f6c\u6362\u8fc7\u7a0b\u662f\uff1aString &#8211;&gt; byte[] &#8211;&gt;String\u3002<br \/>\n\u4e5f\u8bb8 \u4f60\u975e\u5e38\u6e05\u695a\u8fd9\u4e2a\u8fc7\u7a0b\u7684\u4ee3\u7801\uff1anew String(text.getBytes(&#8220;ISO-8859-1&#8243;),&#8221;GBK&#8221;)\u3002\u4f46\u662f\uff0c\u8981\u771f\u6b63\u7406\u89e3\u8d77\u6765\u5e76\u4e0d\u662f\u90a3\u4e48\u7b80\u5355\u3002\u8868\u9762\u4e0a\u770b\u4f3c\u4e4e\u5f88\u5bb9\u6613\u7406\u89e3\uff0c \u4e0d\u5c31\u662f\u5c06text String\u5bf9\u8c61\u6309\u7167ISO-8859-1\u7684\u65b9\u5f0f\u7f16\u7801\u4e3abyte[]\u7136\u540e\u518d\u628a\u5b83\u6309\u7167GBK\u7684\u65b9\u5f0f\u8f6c\u6362\u4e3aString\u5417\uff1f\u4f46\u662f\u8fd9\u53e5\u4ee3\u7801\u5f88\u5bb9\u6613\u4f1a\u88ab\u8bef\u89e3\u4e3a\uff1a \u201c\u5c06text String\u7531ISO-8859-1\u8f6c\u6362\u4e3aGBK\u7f16\u7801\u201d\uff0c\u8fd9\u79cd\u8bf4\u6cd5\u662f\u9519\u8bef\u7684\u3002\u96be\u9053\u4f60\u89c1\u8fc7\u7528\u8fd9\u6837\u7684\u4ee3\u7801\uff1anew String(text.getBytes(&#8220;GBK&#8221;),&#8221;UTF-8&#8243;)\u6765\u5bf9String\u8fdb\u884c\u7f16\u7801\u8f6c\u6362\u7684\u5417\uff1f<\/p>\n<p>\u4e4b\u6240\u4ee5\u4f60\u4f1a\u7ecf\u5e38\u770b\u5230new String(text.getBytes(&#8220;ISO-8859-1&#8243;),&#8221;GBK&#8221;)\u8fd9\u53e5\u4ee3\u7801\uff0c\u662f\u56e0\u4e3a\u4e00\u4e2aGBK\u7684\u5b57\u8282\u6d41\u88ab\u9519\u8bef\u5730\u4ee5ISO-8859- 1\u7684\u65b9\u5f0f\u8f6c\u6362\u4e3aString\uff08unicode\uff09\u4e86\uff01\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u6700\u666e\u904d\u7684\u5730\u65b9\u662f\u4e00\u4e2aGBK\u7f16\u7801\u7684\u7f51\u9875\u5411\u540e\u53f0\u63d0\u4ea4\u6570\u636e\u7684\u65f6\u5019\uff0c\u5c31\u6709\u53ef\u80fd\u4f1a\u770b\u5230\u8fd9\u53e5\u4ee3\u7801\u7684\u51fa \u73b0\u3002GBK\u7684\u6d41\u88ab\u9519\u8bef\u7684\u5f53\u6210ISO8859-1\u7684\u6d41\uff0c\u6240\u4ee5\u4fbf\u5f97\u5230\u4e86\u4e00\u4e2a\u9519\u8bef\u7684String\u3002\u7531\u4e8eISO8859-1\u662f\u5355\u5b57\u8282\u7f16\u7801\uff0c\u6240\u4ee5\u6bcf\u4e2a\u5b57\u8282\u88ab\u6309\u7167\u539f\u6837 \u8f6c\u6362\u4e3aString\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u867d\u7136\u8fd9\u662f\u4e00\u4e2a\u9519\u8bef\u7684\u8f6c\u6362\uff0c\u4f46\u7f16\u7801\u6ca1\u6709\u6539\u53d8\uff0c\u6240\u4ee5\u6211\u4eec\u4ecd\u7136\u6709\u673a\u4f1a\u628a\u7f16\u7801\u8f6c\u6362\u56de\u6765\uff01\u6240\u4ee5\u90a3\u53e5\u7ecf\u5178\u7684new String(text.getBytes(&#8220;ISO-8859-1&#8243;),&#8221;GBK&#8221;)\u4fbf\u51fa\u73b0\u4e86\u3002<\/p>\n<p>\u5982\u679c\u7cfb\u7edf\u8bef\u4ee5\u4e3a\u662f\u5176\u5b83\u7f16\u7801\u683c\u5f0f\uff0c\u5c31\u6709\u53ef\u80fd\u518d\u4e5f\u8f6c\u6362\u4e0d\u56de\u6765\u4e86\uff0c\u56e0\u4e3a\u7f16\u7801\u8f6c\u6362\u5e76\u4e0d\u662f\u8d1f\u8d1f\u5f97\u6b63\u90a3\u4e48\u7b80\u5355\u7684<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\u4e0e\u7f16\u7801\u95ee\u9898\u4e32\u8bb2\u4e4b\u4e8c&#8211;\u5982\u4f55\u7406\u89e3java\u91c7\u7528Unicode\u7f16\u7801 https:\/\/blog.cs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/posts\/665"}],"collection":[{"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vongg.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=665"}],"version-history":[{"count":11,"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/posts\/665\/revisions"}],"predecessor-version":[{"id":676,"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/posts\/665\/revisions\/676"}],"wp:attachment":[{"href":"https:\/\/vongg.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vongg.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vongg.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}