# cjke-strings

> a set of Chinese Japanese Korean and Emoji strings helpers

Latest version **1.1.22** (published 2026-08-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install cjke-strings
pnpm add cjke-strings
yarn add cjke-strings
bun add cjke-strings
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.22 |
| Published | 2026-08-08 |
| First published | 2018-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 40.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 12 |
| Author | GongT |
| Maintainers | gongt |
| Keywords | CJK, chinese, display width, emoji, string, string width, unicode |

## Links

- npm: https://www.npmjs.com/package/cjke-strings
- Repository: https://github.com/GongT/baobao
- Homepage: https://github.com/GongT/baobao#readme
- Issues: https://github.com/GongT/baobao/issues
- npm.io page: https://npm.io/package/cjke-strings

## Dependencies (3)

- [ansi-regex](https://npm.io/package/ansi-regex.md) ^6.2.2
- [emoji-regex](https://npm.io/package/emoji-regex.md) ^10.6.0
- [is-fullwidth-code-point](https://npm.io/package/is-fullwidth-code-point.md) ^5.1.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.22 (latest) — 2026-08-08
- 1.1.21 — 2026-04-13
- 1.1.20 — 2026-04-02
- 1.1.19 — 2026-03-28
- 1.1.18 — 2026-03-26
- 1.1.17 — 2026-03-19
- 1.1.16 — 2026-03-19
- 1.1.15 — 2026-03-19
- 1.1.14 — 2026-02-03
- 1.1.13 — 2026-02-03
- 1.1.12 — 2026-01-17
- 1.1.11 — 2025-09-25
- 1.1.10 — 2025-08-28
- 1.1.9 — 2025-08-20
- 1.1.8 — 2025-08-19
- … 44 more at https://npm.io/package/cjke-strings/versions

## README

[string-width](https://www.npmjs.com/package/string-width) is active maintenance again! Use that package instead.  
This package will mark as deprecated soon.

# CJKE strings module

Tools for **C**hinese **J**apanese **K**orean **E**moji string

The code is come from:

-   Write by myself
-   Codebase is copied from sindresorhus/string-width
-   Learn about emojis from tonytonyjan/string-width
-   Unicode tables copied from many wiki pages

Mostly you also need a module called `stringz`

```typescript
describe('typescript', () => {
	it('is really great', () => {
		should(cleverMan).to.be('using it');
	});
});
```

## APIs

-   isCombiningCharacters - detect a character is in Combining Characters table
-   readFirstCompleteChar - get first complete character at beginning of given string, prevent ￿ or ?
-   unicodeEscape - escape string as "\uxxxx\uxxxx\uxxxx" form
-   limitWidth - cut a limited display width of a string
-   stringWidth - calculate display width of a string

### readFirstCompleteChar(str: string, windowsConsole = false): CodePointInfo

| var            | desc                               |
| -------------- | ---------------------------------- |
| str            | any string                         |
| windowsConsole | is used for windows console or not |

**CodePointInfo**

| var     | type    | desc                       |
| ------- | ------- | -------------------------- |
| data    | string  | first complete char        |
| width   | number  | display width of that char |
| length  | number  | string length of that char |
| visible | boolean | should the char visible?   |

### function limitWidth(str: string, limit: number, windowsConsole = false): LimitResult

| var            | desc                               |
| -------------- | ---------------------------------- |
| str            | any string                         |
| limit          | target display width to cut        |
| windowsConsole | is used for windows console or not |

**LimitResult**

| var    | type   | desc                         |
| ------ | ------ | ---------------------------- |
| result | string | cut result                   |
| width  | number | real display width of result |

### function stringWidth(str: string, windowsConsole = false): number

| var            | desc                               |
| -------------- | ---------------------------------- |
| str            | any string                         |
| windowsConsole | is used for windows console or not |
| {return}       | the display width of str           |

### function isCombiningCharacters(code: number): boolean

| var      | desc                                    |
| -------- | --------------------------------------- |
| code     | return value of `'string'.charCodeAt()` |
| {return} | is in combine char list                 |

### function unicodeEscape(str: string): string

| var      | desc           |
| -------- | -------------- |
| str      | any string     |
| {return} | escaped string |

## Windows console

Windows Console (the black window) is not fully support unicode, so there is some workaround. Default is `false`.

| char | default | when true |
| :--: | ------: | --------: |
|  À   |       1 |         2 |
|  😂̀  |       2 |         3 |
|  À̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀   |       1 |        25 |
|  啊  |       2 |         2 |
|  👍🏽  |       2 |  4(👍+🏽) |

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