add encoding

This commit is contained in:
2020-05-01 10:20:04 +08:00
parent 2f0f0ac68e
commit d72d649d12
3 changed files with 100 additions and 0 deletions

17
encoding/src/main.rs Normal file
View File

@@ -0,0 +1,17 @@
use encoding::{
all::GBK,
Encoding,
EncoderTrap,
DecoderTrap,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let h_china = GBK.encode("Hello 中国", EncoderTrap::Strict)?;
let d_china = GBK.decode(&h_china, DecoderTrap::Strict)?;
println!("{:?}", h_china);
println!("{:?}", d_china);
Ok(())
}