{"id":237037,"date":"2020-12-31T17:43:11","date_gmt":"2020-12-31T09:43:11","guid":{"rendered":"http:\/\/4563.org\/?p=237037"},"modified":"2020-12-31T17:43:11","modified_gmt":"2020-12-31T09:43:11","slug":"js-string-to-hex-%e6%9c%89%e5%93%aa%e4%ba%9b%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e7%9a%84%e5%9c%b0%e6%96%b9%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=237037","title":{"rendered":"js string to hex \u6709\u54ea\u4e9b\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  js string to hex \u6709\u54ea\u4e9b\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : youla <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">  <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/01\/20210101_5fee7e3887bb7.png\" alt=\"js string to hex \u6709\u54ea\u4e9b\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\uff1f\" \/><\/p>\n<p>\u7528 c#\u5199\u4e86\u4e00\u4e2a\u611f\u89c9\u633a\u7b80\u5355\uff0c\u6bd5\u7adf\u5c01\u88c5\u5f97\u5f88\u65e0\u8111\u4e86\u3002<\/p>\n<p>js \u5199\u7684\u8bdd\u5b8c\u5168\u6ca1\u5934\u7eea&#8230;(\u597d\u5427\uff0c\u5176\u5b9e\u5c31\u662f\u61d2)<\/p>\n<p>\u56e0\u4e3a\u63a5\u6536\u5230\u7684\u6570\u636e arrayBuffer<\/p>\n<pre><code>var ws = new WebSocket(\"ws:\/\/localhost:8899\"); ws.binaryType = \"arraybuffer\"; \u2026\u2026 ws.send(\"\u770b\u5230\u8fd9\u884c\u5b57\u7684\u4eba\uff0c\u9e21\u9e21\u7f29\u77ed 10cm\"); \u2026\u2026 ws.onmessage = (e) =&gt;{     var blob = new Blob([new Uint8Array(e.data)]);     var reader = new FileReader();     reader.onload = (evt) =&gt; {         console.log(reader.result);     };     reader.readAsText(blob, \"GB2312\"); }  \/\/\u8fd9\u6837\u8f6c\u5b57\u7b26\u4e32\u4e0d\u4f1a\u4e71\u7801 <\/code><\/pre>\n<p><strong>\u73b0\u5728\u7ea0\u7ed3\u662f arrayBuffer to hex \uff1f\uff1f blob to hex \uff1f\uff1f string to hex \uff1f\uff1f<\/strong><\/p>\n<p>\u627e\u5230\u7684 js string to hex function \u57fa\u672c\u90fd\u662f\u82f1\u6587\u6ca1\u4ec0\u4e48\u95ee\u9898\uff0c\u4f46\u662f\u4e2d\u6587\u6211\u5c06\u6536\u83b7\u4e00\u6bb5\u4e71\u7801\uff1f<\/p>\n<p>\u600e\u4e48\u8f6c\u624d\u4e0d\u4f1a\u51fa\u73b0\u4e71\u7801\u5462\uff1f<\/p>\n<p>stackoverflow \u90fd\u7ffb\u904d\u4e86\uff0cjsdelivr \u4e5f\u7ffb\u904d\u4e86\uff0c\u9c7c\u4e5f\u6478\u8fc7\u4e86\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4684701\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : KuroNekoFan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             js \u7684 string to hex \u53ea\u8981 Number(`$hexString`)\u5c31\u53ef\u4ee5\u4e86&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4684702\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : KuroNekoFan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u9519\u95ee\u9898\uff0c\u5ffd\u7565&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4684703\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dulife <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u614c\uff0c\u7f29\u77ed 10cm \u8fd8\u5269 30cm                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4684704\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GTim <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u95ee\u9898\u7684\u5173\u952e\u5728\u4e8e\u4f60\u7684\u7f16\u7801\uff0c\u4f60\u540e\u7aef\u8fd4\u56de\u7684\u662f `gb2312`<\/p>\n<p>\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528 `TextEncode` \u548c `TextDecode` \u8bd5\u4e00\u8bd5                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4684705\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : youla <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @GTim \u8fd9\u4e2a\u4e0d\u662f\u539f\u751f\u5c31\u6709\u7684\u5427\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4684706\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : youla <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @GTim \u89e3\u51b3\u4e86\uff0c\u8c22\u8c22\uff0c\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u4e4b\u524d\u6ca1\u627e\u5230\u8fd9\u4e2a\u65b9\u6cd5\uff0c\u6211\u8fd8\u4ee5\u4e3a\u8981\u5f15\u7528\u4ec0\u4e48 library                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4684707\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : seki <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u4e0d\u7528\u517c\u5bb9 ie \u53ef\u4ee5\u8003\u8651\u7528\u8fd9\u4e2a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4684708\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GTim <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @seki \u90fd\u539f\u751f websocket \u4e86\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u80af\u5b9a\u80fd\u7528                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>js string to hex &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\/237037"}],"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=237037"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/237037\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=237037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=237037"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=237037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}