{"_id":"simple-wcswidth","_rev":"3804735","name":"simple-wcswidth","description":"Simplified JS/TS implementation of wcswidth() written by Markus Kuhn in C","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"ayonknan","email":""}],"time":{"modified":"2025-06-05T10:57:44.000Z","created":"2020-12-08T08:33:32.874Z","1.0.1":"2020-12-09T09:59:26.049Z","1.0.0":"2020-12-08T08:33:32.874Z"},"users":{},"author":{"name":"Nahiyan Kamal","email":"noyanayihan@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/ayonious/simple-wcswidth.git"},"versions":{"1.0.1":{"name":"simple-wcswidth","version":"1.0.1","description":"Simplified JS/TS implementation of wcswidth() written by Markus Kuhn in C","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/ayonious/simple-wcswidth.git"},"author":{"name":"Nahiyan Kamal","email":"noyanayihan@gmail.com"},"license":"MIT","scripts":{"setup":"yarn","build":"tsc","format":"prettier --write \"**/*.{json,md,ts,tsx,yml,js,jsx}\"","test":"jest --config jestconfig.json","lint":"eslint --ext=js,ts ."},"keywords":["wcwidth","wcswidth","console-width"],"devDependencies":{"@semantic-release/changelog":"^5.0.1","@semantic-release/git":"^9.0.0","@types/jest":"^26.0.16","@typescript-eslint/eslint-plugin":"^4.9.0","@typescript-eslint/parser":"^4.9.0","eslint":"^7.15.0","eslint-config-airbnb-base":"^14.2.1","eslint-config-prettier":"^6.15.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.2.0","husky":"^4.3.0","jest":"^26.6.3","prettier":"^2.2.1","pretty-quick":"^3.1.0","semantic-release":"^17.3.0","ts-jest":"^26.4.4","typescript":"^4.1.2"},"gitHead":"1757e3234c52af3216b4231d8e8f70f7e3853900","bugs":{"url":"https://github.com/ayonious/simple-wcswidth/issues"},"homepage":"https://github.com/ayonious/simple-wcswidth#readme","_id":"simple-wcswidth@1.0.1","_nodeVersion":"12.19.0","_npmVersion":"6.14.8","dist":{"shasum":"8ab18ac0ae342f9d9b629604e54d2aa1ecb018b2","size":6714,"noattachment":false,"key":"/simple-wcswidth/-/simple-wcswidth-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-wcswidth/download/simple-wcswidth-1.0.1.tgz"},"_npmUser":{"name":"ayonknan","email":"jaissatai6@gmail.com"},"directories":{},"maintainers":[{"name":"ayonknan","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-wcswidth_1.0.1_1607507965764_0.2993010266313654"},"_hasShrinkwrap":false,"publish_time":1607507966049,"_cnpm_publish_time":1607507966049,"_cnpmcore_publish_time":"2021-12-16T19:19:04.031Z"},"1.0.0":{"name":"simple-wcswidth","version":"1.0.0","description":"Simplified JS/TS implementation of wcswidth() written by Markus Kuhn in C","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/ayonious/simple-wcswidth.git"},"author":{"name":"Nahiyan Kamal","email":"noyanayihan@gmail.com"},"license":"MIT","scripts":{"setup":"yarn","build":"tsc","format":"prettier --write \"**/*.{json,md,ts,tsx,yml,js,jsx}\"","test":"jest --config jestconfig.json","lint":"eslint --ext=js,ts ."},"keywords":["wcwidth","wcswidth","console-width"],"devDependencies":{"@semantic-release/changelog":"^5.0.1","@semantic-release/git":"^9.0.0","@types/jest":"^26.0.16","@typescript-eslint/eslint-plugin":"^4.9.0","@typescript-eslint/parser":"^4.9.0","eslint":"^7.15.0","eslint-config-airbnb-base":"^14.2.1","eslint-config-prettier":"^6.15.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.2.0","husky":"^4.3.0","jest":"^26.6.3","prettier":"^2.2.1","pretty-quick":"^3.1.0","semantic-release":"^17.3.0","ts-jest":"^26.4.4","typescript":"^4.1.2"},"gitHead":"c93ac76ef290fe7418fe2f1ede0dd35207fb13b5","bugs":{"url":"https://github.com/ayonious/simple-wcswidth/issues"},"homepage":"https://github.com/ayonious/simple-wcswidth#readme","_id":"simple-wcswidth@1.0.0","_nodeVersion":"12.19.0","_npmVersion":"6.14.8","dist":{"shasum":"4f1b000577507c268856198d5d94bc8749cfe45c","size":6600,"noattachment":false,"key":"/simple-wcswidth/-/simple-wcswidth-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-wcswidth/download/simple-wcswidth-1.0.0.tgz"},"_npmUser":{"name":"ayonknan","email":"jaissatai6@gmail.com"},"directories":{},"maintainers":[{"name":"ayonknan","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-wcswidth_1.0.0_1607416412755_0.6520462911507288"},"_hasShrinkwrap":false,"publish_time":1607416412874,"_cnpm_publish_time":1607416412874,"_cnpmcore_publish_time":"2021-12-16T19:19:04.225Z"}},"readme":"<h1 align=\"center\">simple-wcswidth</h1>\n<h3 align=\"center\"> ????️ ???? Simplified JS/TS implementation of wcwidth/wcswidth written by Markus Kuhn in C</h3>\n\n<p align=\"center\">\n  <a href=\"https://codecov.io/gh/ayonious/simple-wcswidth\">\n    <img alt=\"codecov\" src=\"https://codecov.io/gh/ayonious/simple-wcswidth/branch/master/graph/badge.svg\">\n  </a>\n  <a href=\"https://badge.fury.io/js/simple-wcswidth\">\n    <img alt=\"npm version\" src=\"https://badge.fury.io/js/simple-wcswidth.svg\">\n  </a>\n  <a href=\"https://packagephobia.now.sh/result?p=simple-wcswidth\">\n    <img alt=\"install size\" src=\"https://packagephobia.now.sh/badge?p=simple-wcswidth@latest\">\n  </a>\n</p>\n<p align=\"center\">\n  <a href=\"https://github.com/semantic-release/semantic-release\">\n    <img alt=\"semantic-release\" src=\"https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\">\n  </a>\n</p>\n\n# Why another wcswidth?\n\n1. ???? Types included\n2. ???? Installation Size kept as min possible\n3. ???? No Unnecessary dependency added\n4. ???? Tested Automatically and Regularly on different versions of node, including current LTS and stable\n\n# Example Usage\n\n```js\nconst { wcswidth, wcwidth } = require('simple-wcswidth');\n\nconsole.log(wcswidth('Yes 重要')); // 8\nconsole.log(wcswidth('请你')); // 4\nconsole.log(wcswidth('Hi')); // 2\n\nconsole.log(wcwidth('请'.charCodeAt(0))); // 2\n```\n\n# What is simplified here?\n\nIn the original [C code](https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c) there were 2 versions of `wcswidth()` I have included here only for first one, which is applicable for general use.\n\nAbout the second one(WHICH I DIDNT INCLUDE HERE), useful for users of CJK legacy encodings who want to migrate to UCS without changing the traditional terminal character-width behaviour. It is not otherwise recommended for general use.\n\n# Info Taken from Markus Kuhn's [C code](https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c)\n\nThis is an implementation of [wcwidth()](http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html) and [wcswidth()](http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html) (defined in\nIEEE Std 1002.1-2001) for Unicode.\n\nIn fixed-width output devices, Latin characters all occupy a single\n\"cell\" position of equal width, whereas ideographic CJK characters\noccupy two such cells. Interoperability between terminal-line\napplications and (teletype-style) character terminals using the\nUTF-8 encoding requires agreement on which character should advance\nthe cursor by how many cell positions. No established formal\nstandards exist at present on which Unicode character shall occupy\nhow many cell positions on character terminals. These routines are\na first attempt of defining such behavior based on simple rules\napplied to data provided by the Unicode Consortium.\n\nFor some graphical characters, the Unicode standard explicitly\ndefines a character-cell width via the definition of the East Asian\nFullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes.\nIn all these cases, there is no ambiguity about which width a\nterminal shall use. For characters in the East Asian Ambiguous (A)\nclass, the width choice depends purely on a preference of backward\ncompatibility with either historic CJK or Western practice.\nChoosing single-width for these characters is easy to justify as\nthe appropriate long-term solution, as the CJK practice of\ndisplaying these characters as double-width comes from historic\nimplementation simplicity (8-bit encoded characters were displayed\nsingle-width and 16-bit ones double-width, even for Greek,\nCyrillic, etc.) and not any typographic considerations.\n\nMuch less clear is the choice of width for the Not East Asian\n(Neutral) class. Existing practice does not dictate a width for any\nof these characters. It would nevertheless make sense\ntypographically to allocate two character cells to characters such\nas for instance EM SPACE or VOLUME INTEGRAL, which cannot be\nrepresented adequately with a single-width glyph. The following\nroutines at present merely assign a single-cell width to all\nneutral characters, in the interest of simplicity. This is not\nentirely satisfactory and should be reconsidered before\nestablishing a formal standard in this area. At the moment, the\ndecision which Not East Asian (Neutral) characters should be\nrepresented by double-width glyphs cannot yet be answered by\napplying a simple rule from the Unicode database content. Setting\nup a proper standard for the behavior of UTF-8 character terminals\nwill require a careful analysis not only of each Unicode character,\nbut also of each presentation form, something the author of these\nroutines has avoided to do so far.\n\nhttp://www.unicode.org/unicode/reports/tr11/\n\n# LICENSE\n\nMIT\n\nThe original Code written in C was very permissive. You can find it here [Code](http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c)\n","_attachments":{},"homepage":"https://github.com/ayonious/simple-wcswidth#readme","bugs":{"url":"https://github.com/ayonious/simple-wcswidth/issues"},"license":"MIT"}