1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! # encode_rs_transcode
//!
//! This library allows you to easily transcode text within writers.
//!
//! The transcoding is performed by [encoding_rs](https://crates.io/crates/encoding_rs), this library just provides a simple builder to ease the use with external writers.
//!
//! # Use cases
//!
//! - Writing files in a particular format (e.g. writing a CSV file in WINDOWS_1252, using the [csv](https://crates.io/crates/csv) crate)
//!
//! # Example
//!
//! ```rust,ignore
//! extern crate csv;
//! use std::fs::File;
//! use encoding_rs_transcode::{encoding_rs::WINDOWS_1252, TranscoderBuilder};
//!
//! fn main() {
//! // Create a file writer
//! let file = File::create("test.csv").unwrap();
//!
//! // Create a transcoder that'll transcode the input to WINDOWS_1252
//! let transcoder_writer = TranscoderBuilder::new()
//! // .from_encoding(UTF_8) // implied by new()
//! .to_encoding(WINDOWS_1252)
//! .build_writer(file);
//!
//! // Create a CSV writer
//! let mut csv_writer = csv::Writer::from_writer(transcoder_writer);
//! // Write to the CSV file
//! csv_writer.write_record(["foo", "bar"]).unwrap();
//! csv_writer.write_record(["aceio", "àcéîö"]).unwrap();
//!
//! // The CSV file will now be encoded in WINDOWS_1252, without the CSV crate ever
//! // aknowledging the final encoding.
//! // This can be applied to any writer implementing the `Write` trait.
//! }
//! ```
pub use encoding_rs;
use ;
/// A builder struct to create various Transcoders