Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clipcount

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipcount

Reads the clipboard and outputs the character count.

  • 1.0.1
  • PyPI
  • Socket score

Maintainers
1

clipcount

GitHub License PyPI - Version PyPI - Downloads

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

  • Setup
  • Quick Usage
  • Usage
  • Dependencies

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 run the terminal with administrator privileges and then proceed with the installation. For more details, refer to the following article:

Reference: Error installing package with executable · Issue #9023 · pypa/pip

Quick Usage

OptionDescription
clipcount -hDisplay the help screen.
clipcount --help_jpDisplay the help screen in Japanese.
clipcount -bOutput the character count after removing line breaks (\n or \r\n).
clipcount -sOutput the character count after removing half-width spaces.
clipcount -SOutput the character count after removing full-width spaces.
clipcount -tOutput the character count after removing tab characters (\t).
clipcount --splitOutput the character count after removing all whitespace characters (line breaks, half-width spaces, full-width spaces, tabs).
clipcount -mCalculate 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.
CLI
  • Run it as is:
# Output the character count including whitespace characters
$ clipcount
21
  • Remove half-width spaces and output:
# One half-width space is removed and output
$ clipcount -s
20
  • Remove full-width spaces:
# The above spaces are half-width spaces, so nothing changes.
$ clipcount -S
21
  • Remove line breaks:
# Line breaks are removed and output
$ clipcount -b
19
  • Remove all whitespace characters:
# Full-width space characters are removed
$ clipcount -sSbt
18

Alternatively, using --split yields the same result.

# Full-width space characters are removed
$ clipcount --split
18
  • Calculate half-width alphanumeric characters as 0.5 and output:
# Half-width alphanumeric characters are counted as 0.5
$ clipcount -m
10.5
Import

It can also be used in a Python file with "import". As a note, when passing commands to options, please exclude "-" or "--".

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

Usage

clipcount is a Python package that "reads the clipboard and outputs the character count." By default, it outputs the "character count including whitespace characters (line breaks, half-width spaces, full-width spaces, tabs)." It also calculates both half-width and full-width characters as "the same 1 character."

With various options, you can output the character count after removing each whitespace character. When used in the terminal, options can be combined. For example, to output "the character count after removing only full-width spaces and tabs," you can use "clipcount -St".

If you want to remove all whitespace characters at once, the "--split" option can be used. This has the same meaning as "-bsSt".

If you want to calculate half-width and full-width characters separately, you can use the "-m" option. This is an option to calculate half-width characters as "0.5 characters." It may be useful when considering character counts in situations like WordPress titles or meta keywords.

Dependencies

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc