Skip to main content

Module encoding

Module encoding 

Source
Expand description

Character encoding detection and conversion utilities for subtitle files.

This module provides comprehensive tools for handling various character encodings commonly found in subtitle files, including automatic detection and conversion between different encoding formats.

§Main Components

  • analyzer - Statistical analysis of file content for encoding detection
  • charset - Character set definitions and encoding information
  • converter - Encoding conversion functionality
  • detector - High-level encoding detection interface

§Examples

use subx_core::core::formats::encoding::{EncodingDetector, EncodingConverter, Charset};

// Detect encoding of a subtitle file
let detector = EncodingDetector::new()?;
let content = std::fs::read("subtitle.srt")?;
let detected = detector.detect_encoding(&content)?;

// Convert to UTF-8 if needed
if detected.charset != Charset::Utf8 {
    let converter = EncodingConverter::new();
    let converted = converter.convert_to_utf8(&content, &detected.charset)?;
    println!("Converted {} bytes", converted.bytes_processed);
}

Modules§

analyzer
Statistical analysis of file content for encoding detection
charset
Character set definitions and encoding information
converter
Encoding conversion functionality
detector
High-level encoding detection interface

Structs§

ByteAnalyzer
Single-byte and double-byte statistical analyzer
ConversionResult
Result of an encoding conversion operation.
EncodingConverter
Encoding converter
EncodingDetector
Encoding detection engine
EncodingInfo
Encoding detection result information
StatisticalAnalyzer
Statistical language model-based analyzer for encoding detection.

Enums§

Charset
Character encoding types supported by the subtitle processing system.