diff --git a/src/reader.rs b/src/reader.rs index d8be8a6..38b18ab 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -75,11 +75,11 @@ impl Decoder for DecoderReader { } fn read_str(&mut self) -> Result { let len = try!(self.read_uint()); - let mut string = String::new(); + let mut vector = Vec::with_capacity(len as uint); for _ in range(0, len) { - string.push_char(try!(self.reader.read_char())); + vector.push(try!(self.reader.read_u8())); } - Ok(string) + Ok(String::from_utf8(vector).unwrap()) } fn read_enum(&mut self, _: &str, f: |&mut DecoderReader| -> Result) -> Result { diff --git a/src/test.rs b/src/test.rs index 5bd7615..aebaed3 100644 --- a/src/test.rs +++ b/src/test.rs @@ -160,3 +160,9 @@ fn boole(){ the_same(true); the_same(false); } + +#[test] +fn unicode() { + the_same("å".to_string()); + the_same("aåååååååa".to_string()); +}