Skip to main content

clipcount

GitHub License PyPI - Version PyPI - Downloads

This is a Python package that reads text from the clipboard and outputs the character count.

Setup

Install via pip:

pip install clipcount

Handling "Warning" on Windows

If you encounter a "WARNING: The script clipcount.exe is installed in 'path' which is not on PATH." when running the above command on Windows, please refer to the following article.

Reference: 【Python Windows】pip install でPATHが通らない時の解決方法 | ゆすノート

If you see "WARNING: Failed to write executable - trying to use .deleteme logic", please refer to the following article:

Reference: 【Windows】警告が出て「pip install」できない時の解決方法 | ゆすノート

Quick Usage

Option Description
clipcount -h Display the help screen.
clipcount --help_jp Display the help screen in Japanese.
clipcount -b Output the character count after removing line breaks (\n or \r\n).
clipcount -s Output the character count after removing half-width spaces.
clipcount -S Output the character count after removing full-width spaces.
clipcount -t Output the character count after removing tab characters (\t).
clipcount --split Output the character count after removing all whitespace characters (line breaks, half-width spaces, full-width spaces, tabs).
clipcount -m Calculate characters with half-width alphanumeric characters as 0.5 and output the character count.

Use it as a command-line tool to output character counts on the terminal:

clipcount [options]

It can also be imported into Python files:

from clipcount import clipcount
x = clipcount({options})

Example

Note: The examples below are executed in a "Windows" environment, so line breaks are counted as "\r\n".

Copy the following text and run clipcount:

Read
clipboard text.

CUI (Command Line Interface)

  • Run as is:
# Outputs the total number of characters including all whitespace
$ clipcount
23
  • Remove half-width spaces:
# The whitespace in this example is full-width, so nothing changes
$ clipcount -s
23
  • Remove full-width spaces:
# One full-width space is removed from the count
$ clipcount -S
22
  • Remove newline characters:
# Newline characters are removed from the count
$ clipcount -b
21
  • Remove all whitespace characters:
# All whitespace characters are removed
$ clipcount -sSbt
20

Or use --split to get the same result:

# All whitespace characters are removed
$ clipcount --split
20
  • Count half-width alphanumeric characters as 0.5:
# Half-width alphanumeric characters count as 0.5
$ clipcount -m
17.5
  • Remove all whitespace and count half-width characters as 0.5:
$ clipcount -m --split
15.5

Import (Using clipcount in Python)

You can import the clipcount function:

# Store the clipboard character count in a variable
from clipcount import clipcount
x = clipcount({"--split"})
print(x)
# Produces the same result as `clipcount --split`
$ python hoge.py
20

Important note: When using import in Python, do not combine options like -sSbt. Each option must be passed individually in a set.

from clipcount import clipcount

# Correct usage (pass each option separately)
x = clipcount({"-s", "-S", "-b", "-t"})
print(x)

# Incorrect: passing combined options will not work as expected
y = clipcount({"-sSbt"})
print(y)
$ python hoge.py
20  # Output is as if `clipcount -sSbt` was run correctly
23  # The options do not work, so the original character count is returned

Usage

clipcount is a Python package that counts the number of characters in the clipboard.

By default, it counts all characters, including whitespace such as newlines, half-width spaces, full-width spaces, and tabs. It does not distinguish between half-width and full-width characters; all characters are counted as 1 character each.

You can also count characters after removing specific types of whitespace. For example, use -b to remove newlines, -s to remove half-width spaces, -S to remove full-width spaces, and -t to remove tabs.

If you want to remove all whitespace at once, you can use the --split option. This is equivalent to using -b -s -S -t.

Additionally, if you want to distinguish between half-width and full-width characters when counting, you can use the -m option. With this option, half-width characters are counted as 0.5, while full-width characters are counted as 1. This can be useful when checking character counts for WordPress titles, meta keywords, or similar contexts.

You can also combine options in the terminal. For example, to remove only full-width spaces and tabs before counting, you can run:

clipcount -St

You can also use clipcount from Python by importing it. In this case, you should pass each option individually as a set, not as a combined string. For example:

from clipcount import clipcount

x = clipcount({"--split"})
print(x)

Important notes:

  • When using Python, do not combine options like -sSbt; pass each option separately in the set.
  • All options must start with a hyphen (-). Passing options that do not start with a hyphen will raise an error.

Dependencies

Dev-diary

Metadata

Release files for clipcount 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clipcount 1.0.2
File Size Uploaded Provenance Actions
clipcount-1.0.2.tar.gz 6.3 kB Without provenance Details for clipcount-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clipcount 1.0.2
File Interpreter ABI Platform Actions
clipcount-1.0.2-py3-none-any.whl Python 3 none any Details for clipcount-1.0.2-py3-none-any.whl

Total release size: 14.0 kB

Release files / clipcount-1.0.2.tar.gz

Download URL clipcount-1.0.2.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7c4dfa47b624f8be162d267032c52df32e132044258476bfe572dc36c288e52d
BLAKE2b-256 checksum
How to use checksums
f9f5c792b31bec398ed3cdeab5b07c9d0997ba73685fe1fe2b9638a4f68a0e4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.0 CPython/3.13.6 Windows/11

Release files / clipcount-1.0.2-py3-none-any.whl

Download URL clipcount-1.0.2-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08cf66f01836736489243218b1545b33b589fd515ae9b7d6ca6c1793686b0357
BLAKE2b-256 checksum
How to use checksums
ec334a8b8737f21736d55f7ace3ad3dddf2e4f929cdfd207d2ab82c87d3c3283
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.0 CPython/3.13.6 Windows/11

Security for clipcount 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page