or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-9/

File Encoding Analyzer with BOM Detection

A command-line utility that analyzes text files to determine their character encoding, with special handling for Byte Order Mark (BOM) detection.

Capabilities

Detect files with UTF-8 BOM

  • Given a file with UTF-8 BOM, the analyzer correctly identifies it as UTF-8 and reports that a BOM is present @test
  • Given a file with UTF-8 encoding but no BOM, the analyzer identifies it as UTF-8 and reports that no BOM is present @test

Detect files with UTF-16 BOM

  • Given a file with UTF-16LE BOM, the analyzer correctly identifies it as UTF-16LE and reports that a BOM is present @test
  • Given a file with UTF-16BE BOM, the analyzer correctly identifies it as UTF-16BE and reports that a BOM is present @test

Detect files with UTF-32 BOM

  • Given a file with UTF-32LE BOM, the analyzer correctly identifies it as UTF-32LE and reports that a BOM is present @test
  • Given a file with UTF-32BE BOM, the analyzer correctly identifies it as UTF-32BE and reports that a BOM is present @test

Handle files without BOM

  • Given a file without a BOM (e.g., ASCII or ISO-8859-1), the analyzer detects the encoding and reports that no BOM is present @test

Implementation

@generates

API

/**
 * Analyzes a file and returns information about its encoding and BOM presence.
 *
 * @param {string} filePath - Path to the file to analyze
 * @returns {Promise<AnalysisResult>} Analysis result containing encoding and BOM information
 */
async function analyzeFile(filePath) {
  // IMPLEMENTATION HERE
}

/**
 * @typedef {Object} AnalysisResult
 * @property {string|null} encoding - The detected encoding name
 * @property {boolean} hasBOM - Whether a BOM was detected
 * @property {string|null} bomType - The type of BOM if present (e.g., 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-32LE', 'UTF-32BE')
 */

module.exports = {
  analyzeFile,
};

Dependencies { .dependencies }

chardet { .dependency }

Provides character encoding detection support.

@satisfied-by