{"id":188562,"date":"2024-11-11T23:49:25","date_gmt":"2024-11-11T15:49:25","guid":{"rendered":"https:\/\/server.hk\/cnblog\/188562\/"},"modified":"2024-11-11T23:49:27","modified_gmt":"2024-11-11T15:49:27","slug":"%e6%8e%a2%e7%b4%a2gbk%e6%95%b8%e6%93%9a%e5%ba%ab%e4%b8%ademoji%e8%a1%a8%e6%83%85%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e7%ae%a1%e7%90%86-gbk%e6%95%b8%e6%93%9a%e5%ba%abemoji%e8%a1%a8%e6%83%85","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/188562\/","title":{"rendered":"\u63a2\u7d22GBK\u6578\u64da\u5eab\u4e2dEmoji\u8868\u60c5\u7684\u4f7f\u7528\u548c\u7ba1\u7406 (gbk\u6578\u64da\u5eabemoji\u8868\u60c5)"},"content":{"rendered":"<h1 id=\"%e6%8e%a2%e7%b4%a2gbk%e6%95%b8%e6%93%9a%e5%ba%ab%e4%b8%ademoji%e8%a1%a8%e6%83%85%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e7%ae%a1%e7%90%86-BRPumiEbjg\">\u63a2\u7d22GBK\u6578\u64da\u5eab\u4e2dEmoji\u8868\u60c5\u7684\u4f7f\u7528\u548c\u7ba1\u7406<\/h1>\n<p>\u96a8\u8457\u793e\u4ea4\u5a92\u9ad4\u548c\u5373\u6642\u901a\u8a0a\u7684\u666e\u53ca\uff0cEmoji\u8868\u60c5\u5df2\u6210\u70ba\u73fe\u4ee3\u4ea4\u6d41\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u9019\u4e9b\u5c0f\u5716\u6a19\u4e0d\u50c5\u80fd\u5920\u589e\u5f37\u6587\u5b57\u7684\u8868\u9054\u529b\uff0c\u9084\u80fd\u5920\u50b3\u905e\u60c5\u611f\u548c\u610f\u5716\u3002\u7136\u800c\uff0c\u5728\u6578\u64da\u5eab\u4e2d\u5b58\u5132\u548c\u7ba1\u7406\u9019\u4e9bEmoji\u8868\u60c5\u537b\u4e26\u975e\u6613\u4e8b\uff0c\u7279\u5225\u662f\u5728\u4f7f\u7528GBK\u7de8\u78bc\u7684\u6578\u64da\u5eab\u4e2d\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eGBK\u6578\u64da\u5eab\u4e2dEmoji\u8868\u60c5\u7684\u4f7f\u7528\u548c\u7ba1\u7406\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u5efa\u8b70\u548c\u793a\u4f8b\u3002<\/p>\n<h2 id=\"gbk%e7%b7%a8%e7%a2%bc%e7%b0%a1%e4%bb%8b-BRPumiEbjg\">GBK\u7de8\u78bc\u7c21\u4ecb<\/h2>\n<p>GBK\u662f\u4e00\u7a2e\u4e2d\u6587\u5b57\u7b26\u7de8\u78bc\uff0c\u4e3b\u8981\u7528\u65bc\u7c21\u9ad4\u4e2d\u6587\u7684\u6578\u64da\u5b58\u5132\u3002\u5b83\u64f4\u5c55\u4e86GB2312\u7de8\u78bc\uff0c\u652f\u6301\u66f4\u591a\u7684\u6f22\u5b57\u548c\u7b26\u865f\u3002\u7136\u800c\uff0cGBK\u7de8\u78bc\u4e26\u4e0d\u539f\u751f\u652f\u6301Emoji\u8868\u60c5\uff0c\u9019\u4f7f\u5f97\u5728GBK\u6578\u64da\u5eab\u4e2d\u5b58\u5132\u548c\u986f\u793aEmoji\u8b8a\u5f97\u8907\u96dc\u3002<\/p>\n<h2 id=\"emoji%e8%a1%a8%e6%83%85%e7%9a%84%e7%89%b9%e6%80%a7-BRPumiEbjg\">Emoji\u8868\u60c5\u7684\u7279\u6027<\/h2>\n<p>Emoji\u8868\u60c5\u901a\u5e38\u7531\u591a\u500b\u5b57\u7bc0\u7d44\u6210\uff0c\u9019\u4e9b\u5b57\u7bc0\u8d85\u51fa\u4e86GBK\u7de8\u78bc\u7684\u7bc4\u570d\u3002\u5927\u591a\u6578Emoji\u8868\u60c5\u4f7f\u7528UTF-8\u7de8\u78bc\uff0c\u9019\u610f\u5473\u8457\u5728GBK\u6578\u64da\u5eab\u4e2d\u76f4\u63a5\u5b58\u5132Emoji\u6703\u5c0e\u81f4\u6578\u64da\u640d\u58de\u6216\u7121\u6cd5\u6b63\u78ba\u986f\u793a\u3002<\/p>\n<h2 id=\"%e5%9c%a8gbk%e6%95%b8%e6%93%9a%e5%ba%ab%e4%b8%ad%e4%bd%bf%e7%94%a8emoji%e7%9a%84%e6%8c%91%e6%88%b0-BRPumiEbjg\">\u5728GBK\u6578\u64da\u5eab\u4e2d\u4f7f\u7528Emoji\u7684\u6311\u6230<\/h2>\n<ul>\n<li><strong>\u6578\u64da\u640d\u58de\uff1a<\/strong>\u5982\u679c\u5617\u8a66\u5c07Emoji\u76f4\u63a5\u63d2\u5165GBK\u7de8\u78bc\u7684\u6578\u64da\u5eab\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4\u6578\u64da\u640d\u58de\uff0c\u986f\u793a\u70ba\u4e82\u78bc\u3002<\/li>\n<li><strong>\u67e5\u8a62\u554f\u984c\uff1a<\/strong>\u5728\u67e5\u8a62\u5305\u542bEmoji\u7684\u6578\u64da\u6642\uff0c\u53ef\u80fd\u6703\u9047\u5230\u7121\u6cd5\u6b63\u78ba\u5339\u914d\u7684\u60c5\u6cc1\uff0c\u5f71\u97ff\u6578\u64da\u6aa2\u7d22\u7684\u6e96\u78ba\u6027\u3002<\/li>\n<li><strong>\u986f\u793a\u554f\u984c\uff1a<\/strong>\u5373\u4f7f\u6578\u64da\u6210\u529f\u5b58\u5132\uff0c\u61c9\u7528\u7a0b\u5e8f\u5728\u986f\u793a\u9019\u4e9b\u6578\u64da\u6642\u4e5f\u53ef\u80fd\u7121\u6cd5\u6b63\u78ba\u6e32\u67d3Emoji\u3002<\/li>\n<\/ul>\n<h2 id=\"%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88-BRPumiEbjg\">\u89e3\u6c7a\u65b9\u6848<\/h2>\n<p>\u70ba\u4e86\u89e3\u6c7a\u5728GBK\u6578\u64da\u5eab\u4e2d\u4f7f\u7528Emoji\u7684\u554f\u984c\uff0c\u5efa\u8b70\u63a1\u53d6\u4ee5\u4e0b\u5e7e\u7a2e\u65b9\u6cd5\uff1a<\/p>\n<h3 id=\"1-%e4%bd%bf%e7%94%a8utf-8%e7%b7%a8%e7%a2%bc-BRPumiEbjg\">1. \u4f7f\u7528UTF-8\u7de8\u78bc<\/h3>\n<p>\u6700\u76f4\u63a5\u7684\u89e3\u6c7a\u65b9\u6848\u662f\u5c07\u6578\u64da\u5eab\u7684\u7de8\u78bc\u5f9eGBK\u8f49\u63db\u70baUTF-8\u3002\u9019\u6a23\u53ef\u4ee5\u78ba\u4fdd\u6240\u6709\u7684Emoji\u8868\u60c5\u90fd\u80fd\u5920\u6b63\u78ba\u5b58\u5132\u548c\u986f\u793a\u3002\u4ee5\u4e0b\u662fMySQL\u4e2d\u66f4\u6539\u6578\u64da\u5eab\u7de8\u78bc\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>ALTER DATABASE your_database_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;<\/code><\/pre>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8%e8%bd%89%e6%8f%9b%e5%87%bd%e6%95%b8-BRPumiEbjg\">2. \u4f7f\u7528\u8f49\u63db\u51fd\u6578<\/h3>\n<p>\u5982\u679c\u7121\u6cd5\u66f4\u6539\u6578\u64da\u5eab\u7de8\u78bc\uff0c\u53ef\u4ee5\u8003\u616e\u5728\u61c9\u7528\u5c64\u9762\u9032\u884c\u8f49\u63db\u3002\u4f7f\u7528\u7de8\u7a0b\u8a9e\u8a00\u4e2d\u7684\u8f49\u63db\u51fd\u6578\u5c07Emoji\u8f49\u63db\u70ba\u53ef\u5b58\u5132\u7684\u683c\u5f0f\uff0c\u4f8b\u5982\u5c07\u5176\u8f49\u63db\u70baUnicode\u78bc\u9ede\u3002<\/p>\n<pre><code>function emojiToUnicode($emoji) {\n    return json_encode($emoji);\n}<\/code><\/pre>\n<h3 id=\"3-%e4%bd%bf%e7%94%a8%e6%9b%bf%e4%bb%a3%e6%96%b9%e6%a1%88-BRPumiEbjg\">3. \u4f7f\u7528\u66ff\u4ee3\u65b9\u6848<\/h3>\n<p>\u5982\u679c\u4ee5\u4e0a\u65b9\u6cd5\u90fd\u4e0d\u53ef\u884c\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528\u66ff\u4ee3\u65b9\u6848\uff0c\u4f8b\u5982\u5c07Emoji\u8868\u60c5\u66ff\u63db\u70ba\u76f8\u61c9\u7684\u5716\u7247\u6216\u4ee3\u78bc\uff0c\u9019\u6a23\u53ef\u4ee5\u907f\u514d\u7de8\u78bc\u554f\u984c\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-BRPumiEbjg\">\u7d50\u8ad6<\/h2>\n<p>\u5728GBK\u6578\u64da\u5eab\u4e2d\u4f7f\u7528\u548c\u7ba1\u7406Emoji\u8868\u60c5\u662f\u4e00\u500b\u6311\u6230\uff0c\u4f46\u901a\u904e\u9069\u7576\u7684\u7de8\u78bc\u548c\u8f49\u63db\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6c7a\u9019\u4e9b\u554f\u984c\u3002\u96a8\u8457\u6280\u8853\u7684\u9032\u6b65\uff0c\u8d8a\u4f86\u8d8a\u591a\u7684\u61c9\u7528\u7a0b\u5e8f\u548c\u6578\u64da\u5eab\u7cfb\u7d71\u958b\u59cb\u652f\u6301UTF-8\u7de8\u78bc\uff0c\u9019\u4f7f\u5f97Emoji\u7684\u4f7f\u7528\u8b8a\u5f97\u66f4\u52a0\u666e\u904d\u548c\u65b9\u4fbf\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684\u89e3\u6c7a\u65b9\u6848\u4f86\u7ba1\u7406\u60a8\u7684\u6578\u64da\u5eab\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u63d0\u4f9b\u9748\u6d3b\u7684\u6578\u64da\u7ba1\u7406\u9078\u64c7\u548c\u5f37\u5927\u7684\u6027\u80fd\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22GBK\u6578\u64da\u5eab\u4e2dEmoji\u8868\u60c5\u7684\u4f7f\u7528\u548c\u7ba1\u7406\uff0c\u4e86\u89e3\u5982\u4f55\u6709\u6548\u6574\u5408\u548c\u61c9\u7528Emoji\u4ee5\u63d0\u5347\u6578\u64da\u8868\u9054\u548c\u7528\u6236\u4e92\u52d5\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-188562","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/188562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=188562"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/188562\/revisions"}],"predecessor-version":[{"id":188563,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/188562\/revisions\/188563"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=188562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=188562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=188562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}