or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-is-unicode-supported

Detect whether the terminal supports Unicode

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/is-unicode-supported@1.3.x

To install, run

npx @tessl/cli install tessl/npm-is-unicode-supported@1.3.0

index.mddocs/

is-unicode-supported

is-unicode-supported is a lightweight utility library for detecting whether the current terminal environment supports Unicode characters. It provides platform-specific logic to determine Unicode support by checking environment variables and terminal identifiers, making it ideal for command-line tools and CLI applications that need to decide between Unicode symbols and ASCII fallbacks.

Package Information

  • Package Name: is-unicode-supported
  • Package Type: npm
  • Language: JavaScript (ES modules)
  • Installation: npm install is-unicode-supported

Core Imports

import isUnicodeSupported from 'is-unicode-supported';

Note: This package is ESM-only and requires Node.js 12+ with ES module support. CommonJS require() is not supported.

Basic Usage

import isUnicodeSupported from 'is-unicode-supported';

const supportsUnicode = isUnicodeSupported();

if (supportsUnicode) {
    console.log('✅ Unicode is supported - using fancy symbols');
} else {
    console.log('[OK] Unicode not supported - using ASCII fallbacks');
}

Capabilities

Unicode Detection

Detects whether the terminal supports Unicode by examining platform-specific environment variables and terminal identifiers.

/**
 * Detect whether the terminal supports Unicode
 * @returns {boolean} true if the terminal supports Unicode, false otherwise
 */
function isUnicodeSupported(): boolean;

Detection Logic:

For non-Windows platforms (macOS, Linux, etc.):

  • Returns true by default
  • Returns false only if process.env.TERM === 'linux' (Linux console kernel)

For Windows platforms:

  • Returns true if any of the following conditions are met:
    • process.env.CI is truthy (CI environments)
    • process.env.WT_SESSION is truthy (Windows Terminal)
    • process.env.TERMINUS_SUBLIME is truthy (Terminus < v0.2.27)
    • process.env.ConEmuTask === '{cmd::Cmder}' (ConEmu and cmder)
    • process.env.TERM_PROGRAM === 'Terminus-Sublime'
    • process.env.TERM_PROGRAM === 'vscode' (VS Code integrated terminal)
    • process.env.TERM === 'xterm-256color'
    • process.env.TERM === 'alacritty'
    • process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm'
  • Returns false if none of the above conditions are met

Usage Examples:

import isUnicodeSupported from 'is-unicode-supported';

// Simple check
if (isUnicodeSupported()) {
    console.log('🎉 Unicode supported!');
} else {
    console.log('Unicode not supported');
}

// CLI output decision
const checkMark = isUnicodeSupported() ? '✅' : '[OK]';
const crossMark = isUnicodeSupported() ? '❌' : '[FAIL]';

console.log(`${checkMark} Test passed`);
console.log(`${crossMark} Test failed`);

// Progress indicators
const spinner = isUnicodeSupported() ? ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] : ['|', '/', '-', '\\'];

Platform Support

  • Node.js: 12+ (ES modules support required)
  • Windows: Detects specific terminal environments that support Unicode
  • macOS/Linux: Assumes Unicode support except for Linux console kernel
  • CI Environments: Automatically detects CI systems that support Unicode

Dependencies

No runtime dependencies. Uses only Node.js built-in modules:

  • node:process for platform detection and environment variable access