subx_cli/core/formats/encoding/
mod.rs

1//! Character encoding detection and conversion utilities for subtitle files.
2//!
3//! This module provides comprehensive tools for handling various character encodings
4//! commonly found in subtitle files, including automatic detection and conversion
5//! between different encoding formats.
6//!
7//! # Main Components
8//!
9//! - [`analyzer`] - Statistical analysis of file content for encoding detection
10//! - [`charset`] - Character set definitions and encoding information
11//! - [`converter`] - Encoding conversion functionality
12//! - [`detector`] - High-level encoding detection interface
13//!
14//! # Examples
15//!
16//! ```rust,ignore
17//! use subx_cli::core::formats::encoding::{EncodingDetector, EncodingConverter, Charset};
18//!
19//! // Detect encoding of a subtitle file
20//! let detector = EncodingDetector::new()?;
21//! let content = std::fs::read("subtitle.srt")?;
22//! let detected = detector.detect_encoding(&content)?;
23//!
24//! // Convert to UTF-8 if needed
25//! if detected.charset != Charset::Utf8 {
26//!     let converter = EncodingConverter::new();
27//!     let converted = converter.convert_to_utf8(&content, &detected.charset)?;
28//!     println!("Converted {} bytes", converted.bytes_processed);
29//! }
30//! ```
31
32/// Statistical analysis of file content for encoding detection
33pub mod analyzer;
34
35/// Character set definitions and encoding information  
36pub mod charset;
37
38/// Encoding conversion functionality
39pub mod converter;
40
41/// High-level encoding detection interface
42pub mod detector;
43
44pub use analyzer::{ByteAnalyzer, StatisticalAnalyzer};
45pub use charset::{Charset, EncodingInfo};
46pub use converter::{ConversionResult, EncodingConverter};
47pub use detector::EncodingDetector;