Crates.io | utf8_reader |
lib.rs | utf8_reader |
version | 0.7.0 |
source | src |
created_at | 2024-05-10 13:04:24.747119 |
updated_at | 2024-05-12 13:05:59.679596 |
description | A UTF-8 reader that read UTF-8 characters from object that implement Read trait |
homepage | https://github.com/dvorakchen/utf8reader |
repository | https://github.com/dvorakchen/utf8reader |
max_upload_size | |
id | 1235994 |
size | 17,159 |
Read utf-8 characters from object that implement Read trait
use utf8_reader::Utf8Reader;
use std::io::Cursor;
use std::io::Write;
let mut buf = Cursor::new(Vec::new());
buf.write("复/d❤".as_bytes()).unwrap();
buf.set_position(0);
let mut reader = Utf8Reader::new(buf);
assert_eq!(Some('复'.into()), reader.next());
assert_eq!(Some('/'.into()), reader.next());
assert_eq!(Some('d'.into()), reader.next());
assert_eq!(Some('❤'.into()), reader.next());
assert_eq!(None, reader.next());
Note: This Utf8Reader would not validate whether the content is a valid UTF-8