csv_lib/encoders/
big5.rs

1
2pub(crate) fn encode_big5_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_big5(input: &str) -> Vec<u8> {
13    encode_big5_scalar(input)
14}
15
16#[cfg(test)]
17mod tests {
18    use super::*;
19
20    #[test]
21    fn test_encode_big5() {
22        let input = "Hello!";
23        let encoded = encode_big5(input);
24        assert_eq!(encoded, b"Hello!");
25    }
26}