diff --git a/encoding/Cargo.lock b/encoding/Cargo.lock new file mode 100644 index 0000000..1725837 --- /dev/null +++ b/encoding/Cargo.lock @@ -0,0 +1,72 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "encoding" +version = "0.1.0" +dependencies = [ + "encoding 0.2.33", +] + +[[package]] +name = "encoding" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" +dependencies = [ + "encoding-index-japanese", + "encoding-index-korean", + "encoding-index-simpchinese", + "encoding-index-singlebyte", + "encoding-index-tradchinese", +] + +[[package]] +name = "encoding-index-japanese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-korean" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-simpchinese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-singlebyte" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-tradchinese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding_index_tests" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" diff --git a/encoding/Cargo.toml b/encoding/Cargo.toml new file mode 100644 index 0000000..18f1cf3 --- /dev/null +++ b/encoding/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "encoding" +version = "0.1.0" +authors = ["Hatter Jiang "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +encoding = "0.2.33" + diff --git a/encoding/src/main.rs b/encoding/src/main.rs new file mode 100644 index 0000000..9fcaa17 --- /dev/null +++ b/encoding/src/main.rs @@ -0,0 +1,17 @@ +use encoding::{ + all::GBK, + Encoding, + EncoderTrap, + DecoderTrap, +}; + +fn main() -> Result<(), Box> { + let h_china = GBK.encode("Hello 中国", EncoderTrap::Strict)?; + + let d_china = GBK.decode(&h_china, DecoderTrap::Strict)?; + + println!("{:?}", h_china); + println!("{:?}", d_china); + + Ok(()) +}