or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-3/

Text Encoding Analysis Utility

Build a command-line tool that analyzes text files and reports their character encoding along with alternative possibilities ranked by confidence.

Requirements

Your tool should accept a file path as input and produce a detailed analysis report showing:

  1. The most likely encoding detected for the file
  2. A complete list of all possible encoding matches, sorted by confidence level (highest to lowest)
  3. For each encoding match, display:
    • The encoding name
    • The confidence score
    • The language code (if applicable)

The tool should handle both small and large files efficiently.

Test Cases

  • Given a UTF-8 encoded file containing "Hello, World!", the tool identifies UTF-8 as the primary encoding with high confidence @test
  • Given a file with mixed European text, the tool returns multiple ISO-8859 and Windows code page possibilities sorted by confidence @test
  • Given a file path to a non-existent file, the tool handles the error gracefully @test

Implementation

@generates

API

/**
 * Analyzes a file and returns encoding analysis results
 */
export interface EncodingMatch {
  name: string;
  confidence: number;
  language?: string;
}

export interface AnalysisResult {
  primary: string | null;
  alternatives: EncodingMatch[];
}

export function analyzeFile(filepath: string): Promise<AnalysisResult>;

Dependencies { .dependencies }

chardet { .dependency }

Character encoding detection library that provides statistical analysis of text encodings.