Skip to the content.

Alphabetize · NPM version Build Status Coverage Status code style: prettier

To get chinese pinyin or alphabet from chinese. 从汉字提取拼音,返回首字母大写形式;提取首字母,返回大写形式。

Browsers support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Opera
Opera
IE8+ Edge+ last 10 versions last 10 versions last 2 versions last 2 versions last 2 versions

Install

npm i chinese-alphabetize -S
or
yarn add chinese-alphabetize

Usage

import Alphabetize, { getFullChars, getCamelChars } from 'chinese-alphabetize'
or
const Alphabetize, { getFullChars, getCamelChars } = require('chinese-alphabetize')

. getFullChars(提取拼音,返回首字母大写形式)

<
Alphabetize.getFullChars('张三')

->
ZhangSan

. getCamelChars(提取首字母,返回大写形式)

<
Alphabetize.getCamelChars('张三铅')
Alphabetize.getCamelChars('张三铅', { checkPolyphone: true })

->
ZSQ
['ZSQ', 'ZSY']

More