diff --git a/src/reader.rs b/src/reader.rs index e2d1a8e..3a897ad 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -71,10 +71,7 @@ impl<'a, R: Reader+Buffer> Decoder for DecoderReader<'a, R> { } fn read_str(&mut self) -> IoResult { let len = try!(self.read_uint()); - let mut vector = Vec::with_capacity(len as uint); - for _ in range(0, len) { - vector.push(try!(self.reader.read_u8())); - } + let vector = try!(self.reader.read_exact(len)); Ok(String::from_utf8(vector).unwrap()) } fn read_enum(&mut self, _: &str, f: F) -> IoResult where diff --git a/src/test.rs b/src/test.rs index ef3b7c0..cc053ab 100644 --- a/src/test.rs +++ b/src/test.rs @@ -49,6 +49,7 @@ fn test_numbers() { fn test_string() { the_same("".to_string()); the_same("a".to_string()); + the_same("ƒoo".to_string()); } #[test]