or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-5/

Text File Encoding Detector

Build a utility that detects and reports the character encoding of text files.

Capabilities

Detect encoding from binary file data

The utility reads a file as binary data and determines its character encoding.

  • Given a UTF-8 encoded file, the function returns "UTF-8" @test
  • Given a UTF-16LE encoded file, the function returns "UTF-16LE" @test
  • Given a Shift_JIS encoded file containing Japanese text, the function returns "Shift_JIS" @test
  • Given a windows-1252 encoded file, the function returns "windows-1252" @test

Handle unknown encodings

When the encoding cannot be determined, the utility provides appropriate feedback.

  • Given binary data where encoding cannot be detected, the function returns null or "Unknown" @test

Implementation

@generates

API

/**
 * Detects the character encoding of a file
 * @param filePath - Path to the file to analyze
 * @returns The detected encoding name, null if detection fails, or "Unknown"
 */
export function detectFileEncoding(filePath: string): string | null;

Dependencies { .dependencies }

chardet { .dependency }

Provides character encoding detection from binary data.

@satisfied-by