Socket
Socket
Sign inDemoInstall

contains-chinese

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    contains-chinese

Checks whether the input string contains any Chinese text (at least one character). Works with Traditional and Simplified. Unlike the is-chinese package, returns `true` even if the string contains mixed Chinese and non-Chinese characters.


Version published
Weekly downloads
378
decreased by-10.64%
Maintainers
1
Install size
4.68 kB
Created
Weekly downloads
 

Readme

Source

Check whether a string contains any Chinese text

Short sample

const containsChinese = require('contains-chinese');

let t = containsChinese('香港 is cool'); // true
let f = containsChinese('홍콩'); // false - not Chinese

What's it for?

This package provides a way to check whether a string contains any Chinese text. The function will return true if there is at least one Chinese character in the string.

Difference from is-chinese

Another package called is-chinese will return false if the string contains at least one non-Chinese character, for example Welcome to 香港 will result in false.

In contrast, this package will return true for such text containing mixed Chinese and non-Chinese text.

Methods and Static Members

  • containsChinese - returns true if the string has any Chinese characters.
  • containsChinese.HAN_REGEX - contains the regex used for this check.

Comments and suggestions

If you have any comments, contact me here: https://github.com/catcher-in-the-try/

Keywords

FAQs

Last updated on 23 Oct 2017

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