csv_lib/encoders/
windows1251.rs1
2pub(crate) fn encode_windows1251_scalar(input: &str) -> Vec<u8> {
3 input.chars().map(|c| {
4 if c.is_ascii() {
5 c as u8
6 } else {
7 b'?'
8 }
9 }).collect()
10}
11
12pub fn encode_windows1251(input: &str) -> Vec<u8> {
13 encode_windows1251_scalar(input)
14}
15
16#[cfg(test)]
17mod tests {
18 use super::*;
19
20 #[test]
21 fn test_encode_windows1251() {
22 let input = "Win1251";
23 let encoded = encode_windows1251(input);
24 assert_eq!(encoded, b"Win1251");
25 }
26}