• Stars
    star
    119
  • Rank 297,930 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Determine if a string is all Chinese(based on unicode range)

Build Status

JS 中文字符串判断(根据 unicode 编码区间判断)

Determine whether a string is all Chinese(based on unicode range)

install

$ npm install is-chinese

description

Chinese range is based on: https://en.wikipedia.org/wiki/CJK_Unified_Ideographs

usage

const isChinese: (str: string, { includePunctuation }?: {
    includePunctuation?: boolean | undefined;
}) => boolean

example

import isChinese from 'is-chinese'
isChinese('中国').should.true();
isChinese('中国ss').should.false();
isChinese('ss').should.false();
isChinese("\uD842\uDFB7").should.true();

benchmark

isChinese("扁担宽,板凳长,扁担想绑在板凳上。") x 15,813,552 ops/sec ±1.28% (98 runs sampled)
isChinese("ss扁担宽,板凳长,扁担想绑在板凳上。") x 74,815,821 ops/sec ±0.72% (96 runs sampled)
isChinese("扁担宽,板凳长,扁担想绑在板凳上。ss") x 53,410,698 ops/sec ±0.47% (92 runs sampled)
isChinese(chars1000) true x 453,971 ops/sec ±0.57% (100 runs sampled)
isChinese(chars1000WithAscii) false x 2,817,982 ops/sec ±0.36% (90 runs sampled)
Fastest is isChinese("ss扁担宽,板凳长,扁担想绑在板凳上。")

license

MIT

More Repositories

1

node-lessons

📕《Node.js 包教不包会》 by alsotang
JavaScript
16,538
star
2

fast-js

😍 Writing Fast JavaScript
JavaScript
259
star
3

keepagent

🙈又一个GAE翻墙项目。
Python
147
star
4

alsohosts

🚀 一些被封禁域名的 hosts 列表
JavaScript
61
star
5

externalip

get your external ip in Node.js
JavaScript
40
star
6

nslookup

JavaScript
27
star
7

ppp

自动区分国内外线路的路由脚本。
Shell
26
star
8

sql.pegjs

JavaScript
22
star
9

pushbot

A simple push service built on Telegram
TypeScript
17
star
10

libpuzzle_demo

This is a demo project for libpuzzle. The project shows how to use sql-like database to index millions of images.
Python
14
star
11

cf_workers__file

Generate arbitrary size file on Cloudflare Workers
TypeScript
10
star
12

scunews

定时抓取四川大学各个子站点的新闻,并提供 API 供调用。
Python
9
star
13

tableman

A table structure data helper
JavaScript
8
star
14

superagentparse

JavaScript
8
star
15

asdf

tiny static web server that you can launch instantly in any directory (inspired by https://github.com/ddfreyne/adsf/)
JavaScript
8
star
16

cracklocal

破解川大教务系统密码,本地python版。
Python
7
star
17

linabell_stickers

玲娜贝儿表情包收集
JavaScript
7
star
18

goagent_monitor

为公共 GoAgent 集群提供监控服务
Python
6
star
19

is_chinese_rs

detect whether a string is all Chinese
Rust
6
star
20

eventr

A solution to async flow control
JavaScript
6
star
21

ko-timeout

JavaScript
5
star
22

bing-wallpapers

pictures fetched from bing.com
Python
5
star
23

rhooks

custom react hooks including class lifecycle style
TypeScript
4
star
24

hamal

这里都是些 Alsotang 翻译的文字。
4
star
25

uchars

split javascript string to unicode chars correctly
JavaScript
4
star
26

ko-sleep

TypeScript
4
star
27

abutils

utils for AudioBuffer
TypeScript
3
star
28

defo

A method_missing(or Hash.new) lib for JavaScript
JavaScript
3
star
29

co-readline

Read a file line by line in generator/co style
JavaScript
2
star
30

OPENTree0

开源weibo树洞程序。 本程序基于GPLv2协议开源,作者是@戳烧 。
Python
2
star
31

Tang

It's a programming language developed by Chinese.
Python
2
star
32

mobx-react-typescript-boilerplate

TypeScript
2
star
33

simpledownload

A Node.js download package(library)
TypeScript
2
star
34

tencentcloud

JavaScript
2
star
35

ric.js

HTML
2
star
36

gpa

1. 查询川大教务处网站获得JSON格式的已修课程数据 2. 通过数据自动计算绩点
Python
2
star
37

workerrouter

A simple router for Cloudflare Workers.
TypeScript
1
star
38

socks5_rs

Rust
1
star
39

yantl.js

js implement for https://github.com/Yantl/Yantl
JavaScript
1
star
40

jsPattern

Javascript 模式学习笔记
JavaScript
1
star
41

conmarkdown

将Markdown语法转换而来的HTML代码转换回去。
Ruby
1
star
42

portscan

JavaScript
1
star
43

alsotang.github.com

This is a simple blog hosted on GitHub Pages.
HTML
1
star
44

ettr

JavaScript
1
star
45

studytogether

共同学习的项目
C++
1
star
46

blog

Alsotang's blog
1
star
47

littlebee

1
star