JSPM

contains-chinese

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 200
  • Score
    100M100P100Q81338F
  • License ISC

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.

Package Exports

  • contains-chinese

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (contains-chinese) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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/