{"id":60,"date":"2025-02-08T20:31:49","date_gmt":"2025-02-08T12:31:49","guid":{"rendered":"https:\/\/web.eo2suite.cn\/blog\/?p=60"},"modified":"2025-04-03T18:29:26","modified_gmt":"2025-04-03T10:29:26","slug":"%e8%a7%a3%e5%86%b3-emoji-%e6%b8%b2%e6%9f%93%e9%9a%be%e9%a2%98%ef%bc%9aunicode-range-%e4%b8%8e-javascript-%e7%9a%84%e5%ae%8c%e7%be%8e%e7%bb%93%e5%90%88","status":"publish","type":"post","link":"https:\/\/blog.eo2suite.cn\/?p=60","title":{"rendered":"\u89e3\u51b3 Emoji \u6e32\u67d3\u96be\u9898\uff1aUnicode Range \u4e0e JavaScript \u7684\u5b8c\u7f8e\u7ed3\u5408"},"content":{"rendered":"\n<p>Emoji\uff0c\u8fd9\u4e9b\u751f\u52a8\u5f62\u8c61\u7684\u8868\u60c5\u7b26\u53f7\uff0c\u5df2\u7ecf\u6210\u4e3a\u6211\u4eec\u65e5\u5e38\u6c9f\u901a\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u7279\u5b9a\u7684\u6280\u672f\u573a\u666f\u4e0b\uff0c\u4f8b\u5982\u5728\u81ea\u7814\u7684\u5b57\u7b26\u6e32\u67d3\u5f15\u64ce\u4e2d\uff0c\u8981\u6b63\u786e\u6e32\u67d3 Emoji \u5374\u5e76\u975e\u6613\u4e8b\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8 Emoji \u7684 Unicode Range\uff0c\u4ee5\u53ca\u5982\u4f55\u5728 JavaScript \u4e2d\u6b63\u786e\u5904\u7406 Emoji \u7684 Unicode\uff0c\u6700\u7ec8\u5b9e\u73b0 Emoji \u7684\u5b8c\u7f8e\u6e32\u67d3\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Emoji \u4e0e Unicode Range<\/h3>\n\n\n\n<p>Unicode \u662f\u4e00\u79cd\u56fd\u9645\u6807\u51c6\u5b57\u7b26\u96c6\uff0c\u5b83\u4e3a\u4e16\u754c\u4e0a\u51e0\u4e4e\u6240\u6709\u7684\u5b57\u7b26\u90fd\u5206\u914d\u4e86\u4e00\u4e2a\u552f\u4e00\u7684\u6570\u5b57\u7f16\u7801\uff0c\u4e5f\u5c31\u662f\u7801\u70b9\u3002Emoji \u4e5f\u4e0d\u4f8b\u5916\uff0c\u5b83\u4eec\u88ab\u5206\u914d\u5728 Unicode \u7684\u591a\u4e2a\u7801\u70b9\u8303\u56f4\u5185\uff0c\u901a\u5e38\u4f4d\u4e8e\u8865\u5145\u5e73\u9762\uff08Supplementary Multilingual Plane\uff0cSMP\uff09\u4e2d\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u7684\u7801\u70b9\u503c\u5927\u4e8e <code>`0xFFFF`<\/code>\u3002<\/p>\n\n\n\n<p>\u5e38\u89c1\u7684 Emoji Unicode Range \u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>**Emoticons (1F600\u20131F64F):**<\/strong> \u5305\u542b\u5404\u79cd\u9762\u90e8\u8868\u60c5\uff0c\u5982\u7b11\u8138\u3001\u54ed\u8138\u3001\u60ca\u8bb6\u7b49\u7b49\u3002<\/li>\n\n\n\n<li><strong>**Symbols &amp; Pictographs (1F300\u20131F5FF):**<\/strong> \u5305\u542b\u5404\u79cd\u7b26\u53f7\u548c\u8c61\u5f62\u6587\u5b57\uff0c\u5982\u98df\u7269\u3001\u4ea4\u901a\u5de5\u5177\u3001\u5730\u70b9\u7b49\u7b49\u3002<\/li>\n\n\n\n<li><strong>**Transport &amp; Map Symbols (1F680\u20131F6FF):**<\/strong> \u5305\u542b\u4ea4\u901a\u5de5\u5177\u548c\u5730\u56fe\u76f8\u5173\u7684\u7b26\u53f7\u3002<\/li>\n\n\n\n<li><strong>**Miscellaneous Symbols and Pictographs (1F900\u20131F9FF):**<\/strong> \u5305\u542b\u5404\u79cd\u6742\u9879\u7b26\u53f7\u548c\u8c61\u5f62\u6587\u5b57\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u7531\u4e8e Emoji \u7684\u7801\u70b9\u503c\u53ef\u80fd\u8d85\u51fa\u57fa\u672c\u591a\u6587\u79cd\u5e73\u9762\uff08Basic Multilingual Plane\uff0cBMP\uff09\uff0c\u56e0\u6b64\u4f20\u7edf\u7684\u5b57\u7b26\u5904\u7406\u65b9\u6cd5\u53ef\u80fd\u4f1a\u9047\u5230\u95ee\u9898\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e24\u79cd\u6e32\u67d3\u6a21\u5f0f\u4e0b\u7684 Emoji \u6311\u6218<\/h3>\n\n\n\n<p>\u5728\u6211\u4eec\u7684\u573a\u666f\u4e2d\uff0c\u5b58\u5728\u4e24\u79cd\u5b57\u7b26\u6e32\u67d3\u6a21\u5f0f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>**\u57fa\u4e8e\u5b57\u4f53\u6587\u4ef6\u7684\u5b57\u7b26\u6e32\u67d3\uff1a**<\/strong> \u8fd9\u79cd\u6a21\u5f0f\u4f9d\u8d56\u4e8e\u5b57\u4f53\u6587\u4ef6\u6765\u6e32\u67d3\u5b57\u7b26\uff0c\u5305\u62ec Emoji\u3002\u5982\u679c\u7f3a\u5c11 Emoji \u5b57\u4f53\u6587\u4ef6\uff0c\u5219\u65e0\u6cd5\u6e32\u67d3 Emoji\u3002\u5373\u4f7f\u63d0\u4f9b\u4e86 Emoji \u5b57\u4f53\uff0c\u5982\u4f55\u6b63\u786e\u8bc6\u522b\u548c\u5904\u7406 Emoji \u7684 Unicode \u4e5f\u662f\u4e00\u4e2a\u6311\u6218\u3002<\/li>\n\n\n\n<li><strong>**\u6781\u901f\u6e32\u67d3\u6a21\u5f0f\uff08Canvas.fillText\uff09\uff1a**<\/strong> \u8fd9\u79cd\u6a21\u5f0f\u76f4\u63a5\u4f7f\u7528 Canvas \u7684 <code>`fillText`<\/code> \u65b9\u6cd5\u6765\u7ed8\u5236\u5b57\u7b26\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c\u53ea\u8981\u80fd\u6b63\u786e\u5904\u7406\u5b57\u7b26\u7684 Unicode\uff0c\u5c31\u53ef\u4ee5\u76f8\u5bf9\u7b80\u5355\u5730\u5b9e\u73b0 Emoji \u6e32\u67d3\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u65e0\u8bba\u54ea\u79cd\u6a21\u5f0f\uff0c\u6b63\u786e\u5904\u7406 Emoji \u7684 Unicode \u90fd\u662f\u5173\u952e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f20\u7edf\u65b9\u6cd5\u7684\u95ee\u9898\uff1acharCodeAt \u548c fromCharCode \u7684\u5c40\u9650\u6027<\/h3>\n\n\n\n<p>\u5728\u8fc7\u53bb\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 <code>`String.charCodeAt`<\/code> \u65b9\u6cd5\u548c <code>`String.fromCharCode`<\/code> \u65b9\u6cd5\u6765\u5904\u7406 Unicode \u548c\u8fd8\u539f\u5b57\u7b26\u3002\u7136\u800c\uff0c\u8fd9\u4e24\u79cd\u65b9\u6cd5\u5b58\u5728\u4e00\u4e2a\u5f88\u5927\u7684\u5c40\u9650\u6027\uff1a\u5b83\u4eec\u53ea\u80fd\u5904\u7406\u7801\u70b9\u503c\u5728 <code>`0x0000`<\/code> \u5230 <code>`0xFFFF`<\/code> \u4e4b\u95f4\u7684\u5b57\u7b26\uff0c\u65e0\u6cd5\u6b63\u786e\u5904\u7406 Emoji \u7684 Unicode\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u7801\u70b9\u503c\u4e3a <code>`0x1F600`<\/code> \u7684 Emoji\uff0c<code>`charCodeAt`<\/code> \u65b9\u6cd5\u53ea\u80fd\u8fd4\u56de <code>`0xD83D`<\/code>\uff0c<code>`fromCharCode`<\/code> \u65b9\u6cd5\u4e5f\u53ea\u80fd\u5904\u7406\u5c0f\u4e8e <code>`0xFFFF`<\/code> \u7684\u503c\u3002\u8fd9\u5bfc\u81f4 Emoji \u65e0\u6cd5\u6b63\u786e\u8bc6\u522b\u548c\u6e32\u67d3\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u89e3\u51b3\u65b9\u6848\uff1a\u62e5\u62b1 codePointAt \u548c fromCodePoint<\/h3>\n\n\n\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528 <code>`String.codePointAt`<\/code> \u65b9\u6cd5\u548c <code>`String.fromCodePoint`<\/code> \u65b9\u6cd5\u6765\u66ff\u4ee3 <code>`String.charCodeAt`<\/code> \u65b9\u6cd5\u548c <code>`String.fromCharCode`<\/code> \u65b9\u6cd5\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>**<\/strong><code>`String.codePointAt(index)`<\/code><strong>:**<\/strong> \u8fd4\u56de\u5b57\u7b26\u4e32\u4e2d\u6307\u5b9a\u7d22\u5f15\u4f4d\u7f6e\u5b57\u7b26\u7684 Unicode \u7801\u70b9\u503c\u3002\u5373\u4f7f\u5b57\u7b26\u7684\u7801\u70b9\u503c\u5927\u4e8e <code>`0xFFFF`<\/code>\uff0c\u4e5f\u80fd\u6b63\u786e\u8fd4\u56de\u3002<\/li>\n\n\n\n<li><strong>**<\/strong><code>`String.fromCodePoint(codePoint)`<\/code><strong>:**<\/strong> \u4f7f\u7528\u6307\u5b9a\u7684 Unicode \u7801\u70b9\u503c\u521b\u5efa\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e24\u4e2a\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u6b63\u786e\u5730\u83b7\u53d6\u548c\u8fd8\u539f Emoji \u7684 Unicode \u7801\u70b9\u503c\uff0c\u4ece\u800c\u4e3a Emoji \u7684\u6b63\u786e\u6e32\u67d3\u5960\u5b9a\u57fa\u7840\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u83b7\u53d6 Emoji \u7684 Unicode \u7801\u70b9\nconst emoji = '\ud83d\ude00';\nconst codePoint = emoji.codePointAt(0); \/\/ 128512 (0x1F600)\n\n\/\/ \u4f7f\u7528 Unicode \u7801\u70b9\u8fd8\u539f Emoji\nconst restoredEmoji = String.fromCodePoint(codePoint); \/\/ \"\ud83d\ude00\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b57\u7b26\u904d\u5386\u4e0e\u5b57\u5f62\u6d4b\u91cf<\/h3>\n\n\n\n<p>\u5728\u4f7f\u7528 <code>`codePointAt`<\/code> \u548c <code>`fromCodePoint`<\/code> \u540e\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u6ce8\u610f\u4e00\u4e2a\u95ee\u9898\uff1a\u7531\u4e8e Emoji \u7684\u7801\u70b9\u503c\u53ef\u80fd\u5927\u4e8e <code>`0xFFFF`<\/code>\uff0c\u8fd9\u610f\u5473\u7740\u4e00\u4e2a Emoji \u5b57\u7b26\u53ef\u80fd\u5360\u7528\u4e24\u4e2a JavaScript \u5b57\u7b26\u7684\u4f4d\u7f6e\uff08UTF-16 \u7f16\u7801\uff09\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u5728\u4e4b\u524d\u9010\u4e2a\u5b57\u7b26\u8fdb\u884c\u6d4b\u91cf\u548c\u586b\u5145\u7684\u903b\u8f91\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u8bc6\u522b\u4e00\u4e2a\u5b57\u7b26\u662f\u5426\u5360\u7528\u4e24\u4e2a\u5355\u4f4d\u7684\u5b57\u7b26\uff0c\u7136\u540e\u8fdb\u884c\u76f8\u5e94\u7684\u5904\u7406\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u6211\u4eec\u9700\u8981\u5224\u65ad <code>`codePointAt`<\/code> \u8fd4\u56de\u7684\u7801\u70b9\u503c\u662f\u5426\u5927\u4e8e <code>`0xFFFF`<\/code>\uff0c\u5982\u679c\u5927\u4e8e\uff0c\u5219\u9700\u8981\u8df3\u8fc7\u4e0b\u4e00\u4e2a\u5b57\u7b26\uff0c\u56e0\u4e3a\u5b83\u5b9e\u9645\u4e0a\u662f\u5f53\u524d Emoji \u7684\u4e00\u90e8\u5206\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const text = 'Hello \ud83d\ude00 World';\nfor (let i = 0; i &lt; text.length; i++) {\n  const codePoint = text.codePointAt(i);\n  console.log(`Character at index ${i}: ${String.fromCodePoint(codePoint)}, Code Point: ${codePoint}`);\n\n  if (codePoint &gt; 0xFFFF) {\n    i++; \/\/ \u8df3\u8fc7\u4e0b\u4e00\u4e2a\u5b57\u7b26\n  }\n\n  \/\/ \u8fdb\u884c\u5b57\u7b26\u6d4b\u91cf\u548c\u586b\u5145\n  \/\/ ...\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Combined Emoji \u7684\u6311\u6218<\/h3>\n\n\n\n<p>\u9664\u4e86\u5355\u4e2a Emoji \u4e4b\u5916\uff0c\u8fd8\u5b58\u5728\u4e00\u79cd\u53eb\u505a Combined Emoji \u7684\u7279\u6b8a\u7c7b\u578b\u3002\u8fd9\u4e9b Emoji \u7531\u591a\u4e2a Unicode \u5b57\u7b26\u7ec4\u5408\u800c\u6210\uff0c\u4f8b\u5982\u80a4\u8272\u4fee\u9970\u7b26\u3001\u6027\u522b\u7b26\u53f7\u7b49\u7b49\u3002<\/p>\n\n\n\n<p>Combined Emoji \u7684\u6e32\u67d3\u662f\u4e00\u4e2a\u66f4\u52a0\u590d\u6742\u7684\u95ee\u9898\uff0c\u56e0\u4e3a\u6211\u4eec\u9700\u8981\u6b63\u786e\u5730\u8bc6\u522b\u548c\u7ec4\u5408\u8fd9\u4e9b\u5b57\u7b26\uff0c\u624d\u80fd\u6e32\u67d3\u51fa\u6b63\u786e\u7684 Emoji\u3002\u8fd9\u53ef\u80fd\u9700\u8981\u5bf9\u6574\u4e2a\u6e32\u67d3\u903b\u8f91\u8fdb\u884c\u91cd\u6784\uff0c\u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\u8fdb\u884c\u6d4b\u91cf\u548c\u6e32\u67d3\uff0c\u800c\u4e0d\u662f\u9010\u4e2a\u5b57\u7b26\u8fdb\u884c\u5904\u7406\u3002<\/p>\n\n\n\n<p>\u7136\u800c\uff0c\u5982\u4f55\u6b63\u786e\u5730\u5206\u5272\u5b57\u7b26\u4e32\uff0c\u4ee5\u8bc6\u522b Combined Emoji \u7684\u8fb9\u754c\uff0c\u53c8\u662f\u4e00\u4e2a\u975e\u5e38\u68d8\u624b\u7684\u95ee\u9898\u3002\u8fd9\u53ef\u80fd\u9700\u8981\u501f\u52a9\u590d\u6742\u7684 Unicode \u89c4\u8303\u548c\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u5b9e\u73b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3\u4e0e\u5c55\u671b<\/h3>\n\n\n\n<p>\u901a\u8fc7\u4f7f\u7528 <code>`String.codePointAt`<\/code> \u548c <code>`String.fromCodePoint`<\/code> \u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u51b3 Emoji \u7684 Unicode \u5904\u7406\u95ee\u9898\uff0c\u4e3a Emoji \u7684\u6b63\u786e\u6e32\u67d3\u5960\u5b9a\u57fa\u7840\u3002\u7136\u800c\uff0cCombined Emoji \u7684\u6e32\u67d3\u4ecd\u7136\u662f\u4e00\u4e2a\u6311\u6218\uff0c\u9700\u8981\u8fdb\u4e00\u6b65\u7684\u7814\u7a76\u548c\u5b9e\u8df5\u3002<\/p>\n\n\n\n<p>\u672a\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u65b9\u5411\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>**Unicode \u89c4\u8303\u7684\u6df1\u5165\u7814\u7a76\uff1a**<\/strong> \u66f4\u52a0\u6df1\u5165\u5730\u4e86\u89e3 Unicode \u89c4\u8303\uff0c\u7279\u522b\u662f\u5173\u4e8e Emoji \u548c Combined Emoji \u7684\u90e8\u5206\u3002<\/li>\n\n\n\n<li><strong>**\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5e94\u7528\uff1a**<\/strong> \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u8bc6\u522b\u548c\u5206\u5272 Combined Emoji\u3002<\/li>\n\n\n\n<li><strong>**\u6e32\u67d3\u5f15\u64ce\u7684\u91cd\u6784\uff1a**<\/strong> \u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\u8fdb\u884c\u6d4b\u91cf\u548c\u6e32\u67d3\uff0c\u800c\u4e0d\u662f\u9010\u4e2a\u5b57\u7b26\u8fdb\u884c\u5904\u7406\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5e0c\u671b\u672c\u6587\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3 Emoji \u7684 Unicode Range\uff0c\u4ee5\u53ca\u5982\u4f55\u5728 JavaScript \u4e2d\u6b63\u786e\u5904\u7406 Emoji \u7684 Unicode\uff0c\u6700\u7ec8\u5b9e\u73b0 Emoji \u7684\u5b8c\u7f8e\u6e32\u67d3\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Emoji\uff0c\u8fd9\u4e9b\u751f\u52a8\u5f62\u8c61\u7684\u8868\u60c5\u7b26\u53f7\uff0c\u5df2\u7ecf\u6210\u4e3a\u6211\u4eec\u65e5\u5e38\u6c9f\u901a\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u7279\u5b9a\u7684\u6280\u672f\u573a\u666f\u4e0b\uff0c\u4f8b\u5982 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[8],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-technology-sharing","tag-emoji"],"_links":{"self":[{"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=60"}],"version-history":[{"count":2,"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":195,"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions\/195"}],"wp:attachment":[{"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.eo2suite.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}