Skip to content
Detect if a string contains traditional or simplified Chinese characters
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
TradOrSimp.js
package.json
readme.md

readme.md

traditional-or-simplified

Detect if a string contains Simplified or Traditional Chinese characters.

Installation & usage

Install traditional-or-simplified via NPM:

npm install traditional-or-simplified

In Node:

var TradOrSimp = require('traditional-or-simplified');

// Detect if a string contains Simplified Chinese
TradOrSimp.isSimplified('无需注册或设置')
// True

// Detect if a string contains Traditional Chinese
TradOrSimp.isTraditional('無需帳戶或註冊。')
// True

// Detect if a string contains Traditional or Simplified Chinese characters
TradOrSimp.detect('無需帳戶或註冊。')

{ inputLength: 8, // Length of input string
  simplifiedCharacters: 0, // Count of Simplified Chinese characters
  traditionalCharacters: 4, // Count of Traditional Chinese characters
  detectedCharacters: 'traditional', // Detected character set
  detectionRate: 1 } // Ratio of majority/minority character sets

About

Traditional-or-simplified was built by Nick Drewe to detect the Chinese character set of pages being published on wethrift (github) and publishthis.email.

You can’t perform that action at this time.