{"id":85775,"date":"2020-05-15T21:49:49","date_gmt":"2020-05-15T13:49:49","guid":{"rendered":"http:\/\/4563.org\/?p=85775"},"modified":"2020-05-15T21:49:49","modified_gmt":"2020-05-15T13:49:49","slug":"java-%e5%ad%97%e8%8a%82%e6%95%b0%e7%bb%84%e9%80%9a%e8%bf%87-utf-8-%e7%bc%96%e7%a0%81%e6%88%90%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%90%8e%ef%bc%8c%e6%97%a0%e6%b3%95%e6%81%a2%e5%a4%8d%e5%88%b0%e5%8e%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=85775","title":{"rendered":"Java \u5b57\u8282\u6570\u7ec4\u901a\u8fc7 UTF-8 \u7f16\u7801\u6210\u5b57\u7b26\u4e32\u540e\uff0c\u65e0\u6cd5\u6062\u590d\u5230\u539f\u59cb\u5b57\u8282\u6570\u7ec4"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Java \u5b57\u8282\u6570\u7ec4\u901a\u8fc7 UTF-8 \u7f16\u7801\u6210\u5b57\u7b26\u4e32\u540e\uff0c\u65e0\u6cd5\u6062\u590d\u5230\u539f\u59cb\u5b57\u8282\u6570\u7ec4               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yanshenxian <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4ee3\u7801\u5982\u4e0b<\/p>\n<pre><code>byte[] bytes = new byte[] {39, 10, -111, -111, 54, 68, -2, 89, 68, 20, -92, 73, -83, -11, -5, -54, -122, -127, 97, 64}; String stringValue = new String(bytes, StandardCharsets.UTF_8); byte[] newBytes1 = stringValue.getBytes(StandardCharsets.UTF_8); byte[] newBytes2 = stringValue.getBytes(StandardCharsets.ISO_8859_1); \/\/ \u8f93\u51fa false System.out.println(Arrays.equals(bytes, newBytes1)); \/\/ \u8f93\u51fa false System.out.println(Arrays.equals(bytes, newBytes2)); <\/code><\/pre>\n<p>\u6211\u8981\u600e\u4e48\u5c06\u4e00\u4e2a UTF-8 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u6062\u590d\u6210\u539f\u59cb\u5b57\u8282\u6570\u7ec4\u5462<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1516981\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanshenxian <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u81ea\u7b54: \u5728 Stack Overflow \u4e0a\u627e\u5230\u7b54\u6848\u4e86<br \/>is-there-a-way-to-recover-a-byte-array-that-represents-a-string-that-is-saved-a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Java \u5b57\u8282\u6570\u7ec4\u901a\u8fc7 UTF-8&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85775"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85775"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85775\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85775"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}