{"id":17148695,"url":"https://github.com/oxoyo/wechat-emojify","last_synced_at":"2026-01-06T01:02:38.567Z","repository":{"id":86506753,"uuid":"268502666","full_name":"OXOYO/wechat-emojify","owner":"OXOYO","description":"Convert wechat emoji to javascript utf-16 emoji","archived":false,"fork":false,"pushed_at":"2020-04-16T15:10:34.000Z","size":750,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T16:44:01.901Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OXOYO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-01T11:27:17.000Z","updated_at":"2021-03-25T09:40:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"10de7758-7088-4e09-b135-864136f583eb","html_url":"https://github.com/OXOYO/wechat-emojify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXOYO%2Fwechat-emojify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXOYO%2Fwechat-emojify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXOYO%2Fwechat-emojify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXOYO%2Fwechat-emojify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OXOYO","download_url":"https://codeload.github.com/OXOYO/wechat-emojify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245265814,"owners_count":20587397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T21:29:33.090Z","updated_at":"2026-01-06T01:02:38.535Z","avatar_url":"https://github.com/OXOYO.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# wechat-emojify\n\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n\n在网页上正确显示微信昵称中的 `emoji`\n\n## Background\n\n微信有一套自己的 emoji 编码，即类似 `'\\uexxx', x=[0-9a-f]` 的格式。在请求微信获取用户信息时，用户昵称中的 emoji 会以微信的 emoji 编码方式返回，虽然该编码在微信中能够正常解析，但在浏览器中会往往被渲染成小方块 ``。这时需要我们对用户昵称进行一些特殊处理，才能使其正常显示。\n\n## Install\n\n```bash\nyarn add wechat-emojify\n```\n\n## Usage\n\n```javascript\nimport { wechatEmojify, wechatEmojiMap } from 'wechat-emojify'\n// or:\n// import wechatEmojify from 'wechat-emojify'\n\n// single emoji\nwechatEmojify('\\ue404') // 😁\n// emoji in a string\nwechatEmojify('I love you \\ue327') // I love you 💓\n// mixed wechat-emoji and utf-16-emoji\nwechatEmojify('\\ue32c I love you \\ud83d\\udc93') // 💛 I love you 💓\n\n// use emoji map directly\nwechatEmojiMap['\\ue404'] // 😁\n```\n\n## 自己生成 emoji 对照表\n\n```javascript\n/* 请在浏览器控制台中粘贴以下代码 */\nvar emoji = ''\nvar noop = function() {}\nvar copy = copy || noop\nvar genCode = (start, end) =\u003e\n    [...Array(end - start + 1)].map((_, i) =\u003e\n        eval(\"'\\\\ue\" + ('00' + (i + start + 1).toString(16)).slice(-3) + \"'\")\n    )\n// 每组字符范围的终点位置不确定，可自行调整\nvar code = [\n    [0x000, 0x059],\n    [0x100, 0x159],\n    [0x200, 0x252],\n    [0x300, 0x34c],\n    [0x400, 0x44b],\n    [0x500, 0x536]\n]\n    .map(([start, end]) =\u003e genCode(start, end))\n    .reduce((a, b) =\u003e a.concat(b), [])\nif (emoji) {\n    var emojiList = emoji.split(',')\n    var emojiMap = code.reduce((map, char, idx) =\u003e {\n        map[char] = emojiList[idx]\n        return map\n    }, {})\n    var result = JSON.stringify(emojiMap, null, 2)\n    console.log(result, copy === noop ? '' : '\\n\\nemoji 对照表已复制到剪贴板')\n    copy(result)\n} else {\n    var joined = code.join(',')\n    copy(joined)\n    console.log(\n        [\n            `请在微信客户端粘贴以下代码, 并将生成的emoji文本复制到上方的emoji变量处；`,\n            `然后重新运行脚本，即可自动复制 emoji 对照表至剪贴板。`,\n            `\\n${joined}\\n`,\n            copy === noop ? '' : `(已复制，请到微信中粘贴)`\n        ].join('\\n')\n    )\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxoyo%2Fwechat-emojify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxoyo%2Fwechat-emojify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxoyo%2Fwechat-emojify/lists"}