Reading Character by Character

You can use the relision::decoder module to iterate through a stream character by character. The decoder is based on the Encoding Standard and handles UTF-8 and UTF-16 little- and big-endian.

Using this is pretty simple.

  1. use relision::decoder;
  2.  
  3. fn main() {
  4. // Copy the standard in to the standard out, one character at a time.
  5. let mut source = std::io::stdin();
  6. let decode = decoder::Decode::with_capacity(&mut source, 16);
  7. for ch in decode {
  8. println!("{}", ch);
  9. }
  10. }
  • lib/decoder.txt
  • Last modified: 2019/01/08 08:09
  • by sprowell