Skip to content
Divide character strings into graphemes.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci build -> test -> publish by npm prepublish (#8) Apr 17, 2019
src
test Support Malayalam, Kannada, Gujarati (#14) Jul 16, 2019
.babelrc remove "targets" options from preset-env (#10) Apr 17, 2019
.gitignore
README.md
package-lock.json
package.json

README.md

split-graphemes

Divide ligature letters such as Thai, Khmer letters and complex emoji into array of graphemes. You can simply use this library instead of Array.from to get graphemes.

CircleCI

Installation

$ npm install split-graphemes

Examples

Emoji

// An emoji '👨‍👩‍👦‍👦' consists of 4 people face emoji joined by Zero Width Joiners (ZWJ).
const chars = Array.from('👨‍👩‍👦‍👦') // ['👨', ZWJ, '👩', ZWJ, '👦', ZWJ, '👦']
// It is interpreted exactly as one character!
const chars = splitGraphemes('👨‍👩‍👦‍👦') // ['👨‍👩‍👦‍👦']

Khmer characters

Array.from('ប៉ុស្ដិ៍') // ['ប', '៉', 'ុ', 'ស', '្', 'ដ', 'ិ', '៍']
splitGraphemes('ប៉ុស្ដិ៍') // ['ប៉ុ', 'ស្ដិ៍']

Japanese

splitGraphemes('こんにちは') // ['こ', 'ん', 'に', 'ち', 'は']

English

splitGraphemes('Hello') // ['H', 'e', 'l', 'l', 'o']

Supported ligature characters

The list of characters is at here.

You can’t perform that action at this time.