Socket
Socket
Sign inDemoInstall

cn-chars

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cn-chars

一个对简体和繁体汉字相互转化的Node.js模块


Version published
Maintainers
1
Install size
21.9 kB
Created

Readme

Source

cn-chars

一个对简体和繁体汉字相互转化的Node.js模块

build status

使用

var cnchars = require('cn-chars');

接口

toSimplifiedChar(cnChar)

转化输入的汉字cnChar为简体形式。若输入的汉字为简体形式,则输出原汉字;若输入的汉字无相应简体形式,则输出原汉字。函数只接受一个汉字的输入,多余汉字将被忽略。

toTraditionalChar(cnChar)

转化输入的汉字cnChar为繁体形式。若输入的汉字为繁体形式,则输出原汉字;若输入的汉字无相应繁体形式,则输出原汉字。函数只接受一个汉字的输入,多余汉字将被忽略。

示例

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

Keywords

FAQs

Last updated on 23 Jul 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc