or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-2/

File Encoding Analyzer

Build a tool that analyzes text files from a directory and reports the character encoding of each file. The tool must use synchronous operations to process files.

Requirements

The tool accepts a directory path as input and scans all .txt files in that directory. For each file, it determines the character encoding synchronously and returns the results.

Output format:

  • Filename (string)
  • Detected encoding (string, or "unknown" if detection fails)
  • Status ("pass" if encoding detected, "fail" if not)

Capabilities

File discovery

  • Given a directory containing three .txt files ("sample1.txt", "sample2.txt", "sample3.txt"), returns results for all three files @test

Encoding detection

  • Given a file containing UTF-8 text, detects and returns "UTF-8" as the encoding @test
  • Given a file containing ASCII text, detects and returns "ASCII" as the encoding @test

Unknown encoding handling

  • Given a file where encoding cannot be determined, returns "unknown" with status "fail" @test

Implementation

@generates

API

/**
 * Analyzes all .txt files in a directory and returns encoding information
 *
 * @param directoryPath - Path to the directory to analyze
 * @returns Array of file analysis results
 */
export interface FileAnalysisResult {
  filename: string;
  encoding: string;
  status: 'pass' | 'fail';
}

export function analyzeDirectory(directoryPath: string): FileAnalysisResult[];

Dependencies { .dependencies }

chardet { .dependency }

Provides character encoding detection support.

@satisfied-by