Skip to main content

Reads the clipboard and outputs the character count.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clipcount-1.0.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clipcount-1.0.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file clipcount-1.0.2.tar.gz.

File metadata

  • Download URL: clipcount-1.0.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.13.6 Windows/11

File hashes

Hashes for clipcount-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7c4dfa47b624f8be162d267032c52df32e132044258476bfe572dc36c288e52d
MD5 de3923dc3a76dd4da03e2fa7bb2a89b6
BLAKE2b-256 f9f5c792b31bec398ed3cdeab5b07c9d0997ba73685fe1fe2b9638a4f68a0e4d

See more details on using hashes here.

File details

Details for the file clipcount-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: clipcount-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.13.6 Windows/11

File hashes

Hashes for clipcount-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 08cf66f01836736489243218b1545b33b589fd515ae9b7d6ca6c1793686b0357
MD5 e9ad54b0200a9e4ca646a373400767b2
BLAKE2b-256 ec334a8b8737f21736d55f7ace3ad3dddf2e4f929cdfd207d2ab82c87d3c3283

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page