Skip to content

Latest commit

 

History

History
30 lines (26 loc) · 1.21 KB

readme.md

File metadata and controls

30 lines (26 loc) · 1.21 KB

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.