Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liushuping/cn-chars
一个对简体和繁体汉字相互转化的Node.js模块
https://github.com/liushuping/cn-chars
Last synced: 3 months ago
JSON representation
一个对简体和繁体汉字相互转化的Node.js模块
- Host: GitHub
- URL: https://github.com/liushuping/cn-chars
- Owner: liushuping
- License: mit
- Created: 2014-07-20T16:46:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-19T08:30:17.000Z (over 9 years ago)
- Last Synced: 2024-10-08T04:30:01.618Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 215 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cn-chars
========一个对简体和繁体汉字相互转化的Node.js模块
[![build status](https://travis-ci.org/liushuping/cn-chars.svg)](https://travis-ci.org/liushuping/cn-chars.svg)
## 使用
```javascript
var cnchars = require('cn-chars');
```
## 接口
**toSimplifiedChar(cnChar)**转化输入的汉字`cnChar`为简体形式。若输入的汉字为简体形式,则输出原汉字;若输入的汉字无相应简体形式,则输出原汉字。函数只接受一个汉字的输入,多余汉字将被忽略。
**toTraditionalChar(cnChar)**
转化输入的汉字`cnChar`为繁体形式。若输入的汉字为繁体形式,则输出原汉字;若输入的汉字无相应繁体形式,则输出原汉字。函数只接受一个汉字的输入,多余汉字将被忽略。
## 示例
```javascript
var cnchars = require('cn-chars');
var cnChar = '话';
var result = cnchars.toTraditionalChar(cnChar);
console.log(result); // output: 話cnChar = '鐘';
result = cnchars.toSimplifiedChar(cnChar);
console.log(result); //output: 钟
```## Test
Make sure `mocha` is installed globally```
npm install mocha -g
```
Run `npm test` to run unit test## License
MIT