or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-is-fullwidth-code-point

Check if the character represented by a given Unicode code point is fullwidth

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/is-fullwidth-code-point@5.1.x

To install, run

npx @tessl/cli install tessl/npm-is-fullwidth-code-point@5.1.0

index.mddocs/

is-fullwidth-code-point

Check if the character represented by a given Unicode code point is fullwidth. This package determines whether a Unicode code point represents a character that occupies two columns in monospace environments, which is essential for proper text layout in terminals, text editors, and CLI applications.

Package Information

  • Package Name: is-fullwidth-code-point
  • Package Type: npm
  • Language: JavaScript (ES Module)
  • Installation: npm install is-fullwidth-code-point

Core Imports

import isFullwidthCodePoint from 'is-fullwidth-code-point';

For environments that support dynamic imports:

const { default: isFullwidthCodePoint } = await import('is-fullwidth-code-point');

Architecture

This package provides a simple utility function with a focused API surface:

  • Single Function Export: Default export of isFullwidthCodePoint function
  • Input Validation: Uses Number.isInteger() for robust parameter checking
  • Unicode Classification: Delegates to get-east-asian-width library for accurate East Asian Width property determination
  • Error Handling: Returns false for invalid inputs rather than throwing exceptions
  • Zero Dependencies: Apart from the classification library, no additional runtime dependencies

Basic Usage

import isFullwidthCodePoint from 'is-fullwidth-code-point';

// Check East Asian characters (fullwidth)
isFullwidthCodePoint('谢'.codePointAt(0)); // => true
isFullwidthCodePoint('あ'.codePointAt(0)); // => true  
isFullwidthCodePoint('고'.codePointAt(0)); // => true

// Check ASCII characters (halfwidth)
isFullwidthCodePoint('a'.codePointAt(0)); // => false
isFullwidthCodePoint('1'.codePointAt(0)); // => false

// Using Unicode code points directly
isFullwidthCodePoint(0x1F251); // => true (emoji)
isFullwidthCodePoint(0x1B11E); // => true (musical symbol)
isFullwidthCodePoint(0x201D);  // => false (punctuation)

Capabilities

Fullwidth Code Point Detection

Determines if a Unicode code point represents a fullwidth character according to Unicode East Asian Width properties. Returns true for characters classified as either "Fullwidth (F)" or "Wide (W)" in the Unicode standard.

/**
 * Check if the character represented by a given Unicode code point is fullwidth
 * @param codePoint - The Unicode code point of a character
 * @returns true if the code point represents a fullwidth character, false otherwise
 */
export default function isFullwidthCodePoint(codePoint: number): boolean;

Parameters:

  • codePoint (number): The Unicode code point of a character. Must be an integer value.

Returns:

  • boolean: Returns true if the code point represents a fullwidth character, false otherwise.

Behavior:

  • Returns false for non-integer inputs (including NaN, floating point numbers, and non-numeric values)
  • Uses Number.isInteger() for input validation before processing
  • Delegates to the get-east-asian-width library for Unicode width classification
  • Returns true if the code point is classified as either "Fullwidth" or "Wide" according to Unicode East Asian Width standards
  • Handles the full Unicode range including emoji, symbols, and extended character sets

Error Handling:

  • Invalid inputs (non-integers) return false rather than throwing exceptions
  • No exceptions are thrown for any input value

Usage Examples:

// Common East Asian characters
isFullwidthCodePoint('中'.codePointAt(0)); // => true (Chinese)
isFullwidthCodePoint('に'.codePointAt(0)); // => true (Japanese Hiragana)
isFullwidthCodePoint('한'.codePointAt(0)); // => true (Korean Hangul)

// Emoji and symbols
isFullwidthCodePoint('😀'.codePointAt(0)); // => true (emoji)
isFullwidthCodePoint('♪'.codePointAt(0));  // => true (musical note)

// ASCII and Latin characters  
isFullwidthCodePoint('A'.codePointAt(0));  // => false
isFullwidthCodePoint(' '.codePointAt(0));  // => false (space)
isFullwidthCodePoint('!'.codePointAt(0));  // => false (punctuation)

// Edge cases
isFullwidthCodePoint(NaN);        // => false
isFullwidthCodePoint(3.14);       // => false (not integer)
isFullwidthCodePoint(-1);         // => false (negative)
isFullwidthCodePoint(0);          // => false (null character)

Types

// TypeScript type definitions (when using TypeScript)
export default function isFullwidthCodePoint(codePoint: number): boolean;

Dependencies

This package depends on get-east-asian-width (version ^1.3.1) for Unicode width classification logic. Specifically, it imports and uses two internal functions:

  • _isFullWidth: Determines if a code point represents a fullwidth character (East Asian Width property "F")
  • _isWide: Determines if a code point represents a wide character (East Asian Width property "W")

The function returns true if either classification returns true, covering all characters that occupy two columns in terminal and monospace font environments.