isJapanese method

bool isJapanese (
  1. String input
)

Tests if input consists entirely of Japanese characters.

The input String cannot be null or empty.

isJapanese('泣き虫'); // true
isJapanese('あア'); // true
isJapanese('2月'); // true (zenkaku numbers are allowed)
isJapanese('泣き虫。!〜$'); // true (zenkaku/JA punctuation is allowed)
isJapanese('泣き虫.!~\$'); // false (Latin punctuation is not allowed)
isJapanese('A泣き虫'); // false

Implementation

bool isJapanese(String input) {
  assert(input != null);
  assert(input.isNotEmpty);

  return input.chars.every(_isCharJapanese);
}