# wcsize

> Derived from visualwidth-js this package identifies the size of one characterCode in terminals

Latest version **1.0.0** (published 2015-10-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install wcsize
pnpm add wcsize
yarn add wcsize
bun add wcsize
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-10-31 |
| First published | 2015-10-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Martin Heidegger |
| Maintainers | leichtgewicht |
| Keywords | unicode, visualwidth, terminal, wide character, wc, wide character string, wcs, terminal, width, wcwidth, wcswidth |

## Links

- npm: https://www.npmjs.com/package/wcsize
- Repository: https://github.com/martinheidegger/wcsize
- Homepage: https://github.com/martinheidegger/wcsize#readme
- Issues: https://github.com/martinheidegger/wcsize/issues
- npm.io page: https://npm.io/package/wcsize

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-10-31

## README

[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg?style=flat)](LICENSE.md)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
[![npm version](https://badge.fury.io/js/wcsize.svg)](https://badge.fury.io/js/wcsize)

# wcsize
`wcsize` is a JavaScript CommonJS package that deals with the fact that some characters in monospace font environments (like terminals) are displayed with the size of two characters while others occupy the space of one character.

It is derived (forked) from [wcwidth](https://github.com/timoxley/wcwidth) which is a derivate of [wcwidth.c](http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c) which is custom implemented and seems better tested with japanese than the similar package [visualwidth-js](https://github.com/tokuhirom/visualwidth-js). It differes from both of those packages by only returning the width of one character (as integer!) which is important for performance
reasons.

This is a sister-package of [monospace-char-width](https://github.com/martinheidegger/monospace-char-width) whis is based on `visualwidth-js`.

## Installation & Usage
Install the package with `npm i wcsize --save` and pass the character you want to test like this:

```JavaScript
var wcsize = require('wcsize')

function charSize(string, pos) {
    wcsize(string.charCodeAt(pos), pos > 0 ? string.charCodeAt(pos-1) : 0)
}

charSize('abcd', 0) // 1
```

## Surrogates _or_ Why two character codes?
The size of some characters depends on surrogates which means that depending on the character before their size changes. For it to work appropriately you need to pass-in both the current character code and the one before that.

---
_Source: https://npm.io/package/wcsize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
