360 Secure SkillHub
360 安全技能中心

Wc Chars Tool

提供 wc-chars-tool 字符计数工具,可统计总字符、非空白字符、CJK 字符、字节数和字素簇,支持文本参数、标准输入及文件输入,并可输出 JSON 明细,适用于文本长度限制校验与国际化检查。

dinghaibin
dinghaibin
热度 27.52
最近更新 2026-05-11 17:48:15
分类:效率依赖:代码执行 / 读写文件应用场景:数据处理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add wc-chars-tool
Metadata
name
wc-chars-tool
description
Count characters in text input — total, non-whitespace, CJK, and Unicode-aware character counts. Useful for text analysis, content length limits, and i18n validation.

WC Chars Tool — Character Counting Utility

Count characters in text with Unicode awareness. Supports total characters, non-whitespace characters, CJK character detection, and byte-offset reporting. Essential for validating text constraints (SMS, tweets, form fields, database column limits).

Quick Start

# Count characters in a string
wc-chars-tool "Hello, 世界!"

# Count from stdin
echo "Hello World" | wc-chars-tool

# Count characters in a file
wc-chars-tool --file document.txt

Usage

wc-chars-tool [TEXT] [OPTIONS]
wc-chars-tool --file FILE [OPTIONS]

Options:
  --file FILE       Read from file instead of argument
  --bytes           Count bytes instead of characters
  --no-whitespace   Exclude whitespace from count
  --cjk-only        Count only CJK characters
  --graphemes       Count grapheme clusters (user-perceived characters)
  --json            Output as structured JSON
  --detailed        Show breakdown: total, non-ws, digits, punct, spaces

Examples

# Count total characters
wc-chars-tool "Hello World"

# Count bytes in a UTF-8 string
wc-chars-tool "Hello, 世界!" --bytes

# Count non-whitespace characters
wc-chars-tool "Hello World" --no-whitespace

# Count CJK characters only
wc-chars-tool "Hello 你好 世界 world" --cjk-only

# Detailed breakdown
wc-chars-tool "Hello, 世界! 123" --detailed --json

Features

  • Unicode-aware — correctly handles multi-byte characters (CJK, emoji, accents)
  • Grapheme clusters — counts user-perceived characters, not just code points
  • Multiple modes — total, non-whitespace, CJK, byte count
  • Detailed breakdown — digits, punctuation, spaces, letters
  • File and stdin input — flexible input sources
  • JSON output — for monitoring and script integration