encodingbufreader 0.1.1

A BuferReader with encoding.
Documentation
  • Coverage
  • 50%
    4 out of 8 items documented2 out of 7 items with examples
  • Size
  • Source code size: 11.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.57 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • zhnxin/encodingbufreader
    3 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • zhnxin

encoding bufreader

This is a bufreader with ecoding with wrap a BufReader inner.

install

cargo add encodingbufreader

usage

use encodingbufreader::{BufReaderEncoding};
use encoding::all::{UTF_8,GB18030};
let bytes = "This string\nwill be read".as_bytes();

let mut lines_iter = BufReaderEncoding::new(bytes,UTF_8).map(|l| l.unwrap());
assert_eq!(lines_iter.next(), Some(String::from("This string")));
assert_eq!(lines_iter.next(), Some(String::from("will be read")));
assert_eq!(lines_iter.next(), None);

let bytes: &[u8] = &[
            213, 226, 202, 199, 210, 187, 184, 246, 215, 214, 183, 251, 180, 174, 10, 189, 171,
            187, 225, 177, 187, 182, 193, 200, 161,
        ];
for line in BufReaderEncoding::new(bytes, GB18030)
            .lines()
            .map(|l| l.unwrap()){
    println!("{}",line);
            }