diff options
| author | bors <bors@rust-lang.org> | 2013-09-05 15:00:49 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-09-05 15:00:49 -0700 |
| commit | 6f9ce0948a47dbbb5a0ed9aae12e2cce6755465a (patch) | |
| tree | 64a0cb6ba9e7796da1ffad8044dda1bb6d33adf2 /src/libextra | |
| parent | d1dde99e4b3d43d044cdead7240bbd5f0d7a0ce5 (diff) | |
| parent | de39874801761197bf10bf8d04bde1aa2bd82e15 (diff) | |
| download | rust-6f9ce0948a47dbbb5a0ed9aae12e2cce6755465a.tar.gz rust-6f9ce0948a47dbbb5a0ed9aae12e2cce6755465a.zip | |
auto merge of #8997 : fhahn/rust/issue_8985, r=catamorphism,brson
Patch for #8985
Diffstat (limited to 'src/libextra')
| -rw-r--r-- | src/libextra/base64.rs | 6 | ||||
| -rw-r--r-- | src/libextra/bitv.rs | 8 | ||||
| -rw-r--r-- | src/libextra/ebml.rs | 2 | ||||
| -rw-r--r-- | src/libextra/hex.rs | 6 | ||||
| -rw-r--r-- | src/libextra/json.rs | 2 | ||||
| -rw-r--r-- | src/libextra/terminfo/parser/compiled.rs | 2 | ||||
| -rw-r--r-- | src/libextra/uuid.rs | 12 |
7 files changed, 19 insertions, 19 deletions
diff --git a/src/libextra/base64.rs b/src/libextra/base64.rs index b4431004bd7..525ff658dba 100644 --- a/src/libextra/base64.rs +++ b/src/libextra/base64.rs @@ -145,7 +145,7 @@ impl<'self> ToBase64 for &'self [u8] { } unsafe { - str::raw::from_bytes_owned(v) + str::raw::from_utf8_owned(v) } } } @@ -162,7 +162,7 @@ impl<'self> FromBase64 for &'self str { * Convert any base64 encoded string (literal, `@`, `&`, or `~`) * to the byte values it encodes. * - * You can use the `from_bytes` function in `std::str` + * You can use the `from_utf8` function in `std::str` * to turn a `[u8]` into a string with characters corresponding to those * values. * @@ -180,7 +180,7 @@ impl<'self> FromBase64 for &'self str { * printfln!("%s", hello_str); * let bytes = hello_str.from_base64(); * printfln!("%?", bytes); - * let result_str = str::from_bytes(bytes); + * let result_str = str::from_utf8(bytes); * printfln!("%s", result_str); * } * ~~~ diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs index 03588d984d9..70fd3a01ca4 100644 --- a/src/libextra/bitv.rs +++ b/src/libextra/bitv.rs @@ -523,7 +523,7 @@ impl Bitv { * with the most significant bits of each byte coming first. Each * bit becomes true if equal to 1 or false if equal to 0. */ -pub fn from_bytes(bytes: &[u8]) -> Bitv { +pub fn from_utf8(bytes: &[u8]) -> Bitv { from_fn(bytes.len() * 8, |i| { let b = bytes[i / 8] as uint; let offset = i % 8; @@ -1275,8 +1275,8 @@ mod tests { } #[test] - fn test_from_bytes() { - let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]); + fn test_from_utf8() { + let bitv = from_utf8([0b10110110, 0b00000000, 0b11111111]); let str = ~"10110110" + "00000000" + "11111111"; assert_eq!(bitv.to_str(), str); } @@ -1302,7 +1302,7 @@ mod tests { #[test] fn test_to_bools() { let bools = ~[false, false, true, false, false, true, true, false]; - assert_eq!(from_bytes([0b00100110]).to_bools(), bools); + assert_eq!(from_utf8([0b00100110]).to_bools(), bools); } #[test] diff --git a/src/libextra/ebml.rs b/src/libextra/ebml.rs index d8d54e20e97..4e5094dab63 100644 --- a/src/libextra/ebml.rs +++ b/src/libextra/ebml.rs @@ -41,7 +41,7 @@ impl Doc { } pub fn as_str_slice<'a>(&'a self) -> &'a str { - str::from_bytes_slice(self.data.slice(self.start, self.end)) + str::from_utf8_slice(self.data.slice(self.start, self.end)) } pub fn as_str(&self) -> ~str { diff --git a/src/libextra/hex.rs b/src/libextra/hex.rs index d5345cb956b..b93b5fb43d4 100644 --- a/src/libextra/hex.rs +++ b/src/libextra/hex.rs @@ -45,7 +45,7 @@ impl<'self> ToHex for &'self [u8] { } unsafe { - str::raw::from_bytes_owned(v) + str::raw::from_utf8_owned(v) } } } @@ -62,7 +62,7 @@ impl<'self> FromHex for &'self str { * Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`) * to the byte values it encodes. * - * You can use the `from_bytes` function in `std::str` + * You can use the `from_utf8` function in `std::str` * to turn a `[u8]` into a string with characters corresponding to those * values. * @@ -80,7 +80,7 @@ impl<'self> FromHex for &'self str { * printfln!("%s", hello_str); * let bytes = hello_str.from_hex().unwrap(); * printfln!("%?", bytes); - * let result_str = str::from_bytes(bytes); + * let result_str = str::from_utf8(bytes); * printfln!("%s", result_str); * } * ~~~ diff --git a/src/libextra/json.rs b/src/libextra/json.rs index bc8c08d4643..ee3e1966fe2 100644 --- a/src/libextra/json.rs +++ b/src/libextra/json.rs @@ -858,7 +858,7 @@ impl<T : iterator::Iterator<char>> Parser<T> { /// Decodes a json value from an @io::Reader pub fn from_reader(rdr: @io::Reader) -> Result<Json, Error> { - let s = str::from_bytes(rdr.read_whole_stream()); + let s = str::from_utf8(rdr.read_whole_stream()); let mut parser = Parser(~s.iter()); parser.parse() } diff --git a/src/libextra/terminfo/parser/compiled.rs b/src/libextra/terminfo/parser/compiled.rs index 0d2badff492..49a6210e3a9 100644 --- a/src/libextra/terminfo/parser/compiled.rs +++ b/src/libextra/terminfo/parser/compiled.rs @@ -213,7 +213,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> { return Err(~"incompatible file: more string offsets than expected"); } - let names_str = str::from_bytes(file.read_bytes(names_bytes as uint - 1)); // don't read NUL + let names_str = str::from_utf8(file.read_bytes(names_bytes as uint - 1)); // don't read NUL let term_names: ~[~str] = names_str.split_iter('|').map(|s| s.to_owned()).collect(); file.read_byte(); // consume NUL diff --git a/src/libextra/uuid.rs b/src/libextra/uuid.rs index 3159d8a8f3c..9a79e61e233 100644 --- a/src/libextra/uuid.rs +++ b/src/libextra/uuid.rs @@ -210,7 +210,7 @@ impl Uuid { /// /// # Arguments /// * `b` An array or slice of 16 bytes - pub fn from_bytes(b: &[u8]) -> Option<Uuid> { + pub fn from_utf8(b: &[u8]) -> Option<Uuid> { if b.len() != 16 { return None } @@ -307,7 +307,7 @@ impl Uuid { s[i*2+0] = digit[0]; s[i*2+1] = digit[1]; } - str::from_bytes(s) + str::from_utf8(s) } /// Returns a string of hexadecimal digits, separated into groups with a hypen @@ -413,7 +413,7 @@ impl Uuid { ub[i] = FromStrRadix::from_str_radix(vs.slice(i*2, (i+1)*2), 16).unwrap(); } - Ok(Uuid::from_bytes(ub).unwrap()) + Ok(Uuid::from_utf8(ub).unwrap()) } } @@ -705,11 +705,11 @@ mod test { } #[test] - fn test_from_bytes() { + fn test_from_utf8() { let b = ~[ 0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 ]; - let u = Uuid::from_bytes(b).unwrap(); + let u = Uuid::from_utf8(b).unwrap(); let expected = ~"a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8"; assert!(u.to_simple_str() == expected); @@ -729,7 +729,7 @@ mod test { let b_in: [u8, ..16] = [ 0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 ]; - let u = Uuid::from_bytes(b_in.clone()).unwrap(); + let u = Uuid::from_utf8(b_in.clone()).unwrap(); let b_out = u.to_bytes(); |
