https://github.com/alsotang/uchars
split javascript string to unicode chars correctly
https://github.com/alsotang/uchars
Last synced: 3 months ago
JSON representation
split javascript string to unicode chars correctly
- Host: GitHub
- URL: https://github.com/alsotang/uchars
- Owner: alsotang
- Created: 2017-03-23T16:45:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-11-04T02:39:07.000Z (over 2 years ago)
- Last Synced: 2025-03-17T16:12:15.738Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# uchars
## description
split javascript string to unicode chars correctly
## install
`npm install uchars`
## usage
```js
var string = "呵呵😄\uD842\uDFB7哈哈";
// arr would be [ '呵', '呵', '😄', '𠮷', '哈', '哈' ]
var arr = uchars(string)assert(string.length === 8)
assert(arr.length === 6)
assert(arr[2] === '😄')
assert(arr[2].length === 2)
assert(arr[3] === '\uD842\uDFB7')
assert(arr[3] === '𠮷')
```## license
MIT