Detect if a string contains traditional or simplified Chinese characters.
https://www.npmjs.com/package/hanalyzer
| src | Simplify the logic, use a worse name | |
| .gitignore | initial commit | |
| bun.lock | initial commit | |
| bunup.config.ts | initial commit | |
| LICENSE | initial commit | |
| package.json | Simplify the logic, use a worse name | |
| README.md | Simplify the logic, use a worse name | |
| tsconfig.json | initial commit | |
hanalyzer
Detect if a string contains Simplified or Traditional Chinese characters. It’s a bad pun, I know.
Installation & usage
npm install hanalyzer
import { detect } from "hanalyzer";
detect("無需帳戶或註冊。");
// => "traditional"
detect("无需注册或设置");
// => "simplified"
detect("hello?");
// => null
import { hasSimplifiedChars } from "hanalyzer";
hasSimplifiedChars("無需帳戶或註冊。");
// => false
hasSimplifiedChars("無需帳戶或註冊。But also simplified right here: 无");
// => true
Prior art
Loosely based on traditional-or-simplified by @nickdrewe.