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 detectioncharset- Character set definitions and encoding informationconverter- Encoding conversion functionalitydetector- 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§
- Byte
Analyzer - Single-byte and double-byte statistical analyzer
- Conversion
Result - Result of an encoding conversion operation.
- Encoding
Converter - Encoding converter
- Encoding
Detector - Encoding detection engine
- Encoding
Info - Encoding detection result information
- Statistical
Analyzer - Statistical language model-based analyzer for encoding detection.
Enums§
- Charset
- Character encoding types supported by the subtitle processing system.