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/libstd | |
| 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/libstd')
| -rw-r--r-- | src/libstd/fmt/mod.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io.rs | 10 | ||||
| -rw-r--r-- | src/libstd/num/int_macros.rs | 2 | ||||
| -rw-r--r-- | src/libstd/num/strconv.rs | 2 | ||||
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 2 | ||||
| -rw-r--r-- | src/libstd/repr.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/io/file.rs | 14 | ||||
| -rw-r--r-- | src/libstd/rt/io/flate.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/uv/file.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rt/uv/net.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/uv/uvio.rs | 2 | ||||
| -rw-r--r-- | src/libstd/run.rs | 24 | ||||
| -rw-r--r-- | src/libstd/str.rs | 96 | ||||
| -rw-r--r-- | src/libstd/sys.rs | 2 |
14 files changed, 84 insertions, 84 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 8d50f5efa48..ef036340412 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -468,7 +468,7 @@ pub unsafe fn write(output: &mut io::Writer, pub unsafe fn format(fmt: &[rt::Piece], args: &[Argument]) -> ~str { let mut output = MemWriter::new(); write(&mut output as &mut io::Writer, fmt, args); - return str::from_bytes_owned(output.inner()); + return str::from_utf8_owned(output.inner()); } impl<'self> Formatter<'self> { @@ -589,7 +589,7 @@ impl<'self> Formatter<'self> { fn runplural(&mut self, value: uint, pieces: &[rt::Piece]) { do ::uint::to_str_bytes(value, 10) |buf| { - let valuestr = str::from_bytes_slice(buf); + let valuestr = str::from_utf8_slice(buf); for piece in pieces.iter() { self.run(piece, Some(valuestr)); } diff --git a/src/libstd/io.rs b/src/libstd/io.rs index 59329c5bdd2..ee948446614 100644 --- a/src/libstd/io.rs +++ b/src/libstd/io.rs @@ -642,7 +642,7 @@ impl<T:Reader> ReaderUtil for T { } bytes.push(ch as u8); } - str::from_bytes(bytes) + str::from_utf8(bytes) } fn read_line(&self) -> ~str { @@ -651,7 +651,7 @@ impl<T:Reader> ReaderUtil for T { fn read_chars(&self, n: uint) -> ~[char] { // returns the (consumed offset, n_req), appends characters to &chars - fn chars_from_bytes<T:Reader>(bytes: &~[u8], chars: &mut ~[char]) + fn chars_from_utf8<T:Reader>(bytes: &~[u8], chars: &mut ~[char]) -> (uint, uint) { let mut i = 0; let bytes_len = bytes.len(); @@ -701,7 +701,7 @@ impl<T:Reader> ReaderUtil for T { break; } bytes.push_all(data); - let (offset, nbreq) = chars_from_bytes::<T>(&bytes, &mut chars); + let (offset, nbreq) = chars_from_utf8::<T>(&bytes, &mut chars); let ncreq = n - chars.len(); // again we either know we need a certain number of bytes // to complete a character, or we make sure we don't @@ -1761,7 +1761,7 @@ pub fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] { } pub fn with_str_writer(f: &fn(@Writer)) -> ~str { - str::from_bytes(with_bytes_writer(f)) + str::from_utf8(with_bytes_writer(f)) } // Utility functions @@ -1781,7 +1781,7 @@ pub fn seek_in_buf(offset: int, pos: uint, len: uint, whence: SeekStyle) -> pub fn read_whole_file_str(file: &Path) -> Result<~str, ~str> { do read_whole_file(file).chain |bytes| { if str::is_utf8(bytes) { - Ok(str::from_bytes(bytes)) + Ok(str::from_utf8(bytes)) } else { Err(file.to_str() + " is not UTF-8") } diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 0131feda830..377d0a78134 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -541,7 +541,7 @@ impl ToStrRadix for $T { } // We know we generated valid utf-8, so we don't need to go through that // check. - unsafe { str::raw::from_bytes_owned(buf) } + unsafe { str::raw::from_utf8_owned(buf) } } } diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 6fba8a6dd13..edfabd339af 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -417,7 +417,7 @@ pub fn float_to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Float+Round+ sign: SignFormat, digits: SignificantDigits) -> (~str, bool) { let (bytes, special) = float_to_str_bytes_common(num, radix, negative_zero, sign, digits); - (str::from_bytes(bytes), special) + (str::from_utf8(bytes), special) } // Some constants for from_str_bytes_common's input validation, diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 1426142d465..af991045b45 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -396,7 +396,7 @@ impl ToStrRadix for $T { } // We know we generated valid utf-8, so we don't need to go through that // check. - unsafe { str::raw::from_bytes_owned(buf) } + unsafe { str::raw::from_utf8_owned(buf) } } } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 7141a17d133..c03d7bdf6a7 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -634,7 +634,7 @@ fn test_repr() { fn exact_test<T>(t: &T, e:&str) { let mut m = io::mem::MemWriter::new(); write_repr(&mut m as &mut io::Writer, t); - let s = str::from_bytes_owned(m.inner()); + let s = str::from_utf8_owned(m.inner()); assert_eq!(s.as_slice(), e); } diff --git a/src/libstd/rt/io/file.rs b/src/libstd/rt/io/file.rs index 3fb00720406..ad21dfea3cd 100644 --- a/src/libstd/rt/io/file.rs +++ b/src/libstd/rt/io/file.rs @@ -159,7 +159,7 @@ fn file_test_smoke_test_impl() { let mut read_buf = [0, .. 1028]; let read_str = match read_stream.read(read_buf).unwrap() { -1|0 => fail!("shouldn't happen"), - n => str::from_bytes(read_buf.slice_to(n)) + n => str::from_utf8(read_buf.slice_to(n)) }; assert!(read_str == message.to_owned()); } @@ -230,7 +230,7 @@ fn file_test_io_non_positional_read_impl() { } } unlink(filename); - let read_str = str::from_bytes(read_mem); + let read_str = str::from_utf8(read_mem); assert!(read_str == message.to_owned()); } } @@ -262,7 +262,7 @@ fn file_test_io_seeking_impl() { tell_pos_post_read = read_stream.tell(); } unlink(filename); - let read_str = str::from_bytes(read_mem); + let read_str = str::from_utf8(read_mem); assert!(read_str == message.slice(4, 8).to_owned()); assert!(tell_pos_pre_read == set_cursor); assert!(tell_pos_post_read == message.len() as u64); @@ -295,7 +295,7 @@ fn file_test_io_seek_and_write_impl() { read_stream.read(read_mem); } unlink(filename); - let read_str = str::from_bytes(read_mem); + let read_str = str::from_utf8(read_mem); io::println(fmt!("read_str: '%?' final_msg: '%?'", read_str, final_msg)); assert!(read_str == final_msg.to_owned()); } @@ -324,17 +324,17 @@ fn file_test_io_seek_shakedown_impl() { read_stream.seek(-4, SeekEnd); read_stream.read(read_mem); - let read_str = str::from_bytes(read_mem); + let read_str = str::from_utf8(read_mem); assert!(read_str == chunk_three.to_owned()); read_stream.seek(-9, SeekCur); read_stream.read(read_mem); - let read_str = str::from_bytes(read_mem); + let read_str = str::from_utf8(read_mem); assert!(read_str == chunk_two.to_owned()); read_stream.seek(0, SeekSet); read_stream.read(read_mem); - let read_str = str::from_bytes(read_mem); + let read_str = str::from_utf8(read_mem); assert!(read_str == chunk_one.to_owned()); } unlink(filename); diff --git a/src/libstd/rt/io/flate.rs b/src/libstd/rt/io/flate.rs index 16bca850fd2..7c72ce6ba89 100644 --- a/src/libstd/rt/io/flate.rs +++ b/src/libstd/rt/io/flate.rs @@ -117,7 +117,7 @@ mod test { let mut out_bytes = [0, .. 100]; let bytes_read = inflate_reader.read(out_bytes).unwrap(); assert_eq!(bytes_read, in_bytes.len()); - let out_msg = str::from_bytes(out_bytes); + let out_msg = str::from_utf8(out_bytes); assert!(in_msg == out_msg); } } diff --git a/src/libstd/rt/uv/file.rs b/src/libstd/rt/uv/file.rs index eaf70242440..15fe9abaa2c 100644 --- a/src/libstd/rt/uv/file.rs +++ b/src/libstd/rt/uv/file.rs @@ -329,7 +329,7 @@ mod test { if nread > 0 { let read_str = unsafe { let read_buf = *read_buf_ptr; - str::from_bytes( + str::from_utf8( vec::from_buf( read_buf.base, nread)) }; @@ -393,7 +393,7 @@ mod test { // nread == 0 would be EOF.. we know it's >= zero because otherwise // the above assert would fail if nread > 0 { - let read_str = str::from_bytes( + let read_str = str::from_utf8( read_mem.slice(0, nread as uint)); assert!(read_str == ~"hello"); // close diff --git a/src/libstd/rt/uv/net.rs b/src/libstd/rt/uv/net.rs index 3ff6e90e32d..6e890850654 100644 --- a/src/libstd/rt/uv/net.rs +++ b/src/libstd/rt/uv/net.rs @@ -83,7 +83,7 @@ fn uv_socket_addr_as_socket_addr<T>(addr: UvSocketAddr, f: &fn(SocketAddr) -> T) }; port as u16 }; - let ip_str = str::from_bytes_slice(ip_name).trim_right_chars(&'\x00'); + let ip_str = str::from_utf8_slice(ip_name).trim_right_chars(&'\x00'); let ip_addr = FromStr::from_str(ip_str).unwrap(); // finally run the closure diff --git a/src/libstd/rt/uv/uvio.rs b/src/libstd/rt/uv/uvio.rs index e37dfba0cc1..6f9e3c43b0e 100644 --- a/src/libstd/rt/uv/uvio.rs +++ b/src/libstd/rt/uv/uvio.rs @@ -1812,7 +1812,7 @@ fn file_test_uvio_full_simple_impl() { let mut fd = (*io).fs_open(&Path(path), ro_fm, ro_fa).unwrap(); let mut read_vec = [0, .. 1028]; let nread = fd.read(read_vec).unwrap(); - let read_val = str::from_bytes(read_vec.slice(0, nread as uint)); + let read_val = str::from_utf8(read_vec.slice(0, nread as uint)); assert!(read_val == write_val.to_owned()); } (*io).fs_unlink(&Path(path)); diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 7fc2deff97d..0fe9236253d 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -997,7 +997,7 @@ mod tests { let run::ProcessOutput {status, output, error} = run::process_output("echo", [~"hello"]); - let output_str = str::from_bytes(output); + let output_str = str::from_utf8(output); assert_eq!(status, 0); assert_eq!(output_str.trim().to_owned(), ~"hello"); @@ -1012,7 +1012,7 @@ mod tests { let run::ProcessOutput {status, output, error} = run::process_output("/system/bin/sh", [~"-c",~"echo hello"]); - let output_str = str::from_bytes(output); + let output_str = str::from_utf8(output); assert_eq!(status, 0); assert_eq!(output_str.trim().to_owned(), ~"hello"); @@ -1091,7 +1091,7 @@ mod tests { let reader = io::FILE_reader(file, false); let buf = reader.read_whole_stream(); os::fclose(file); - str::from_bytes(buf) + str::from_utf8(buf) } } @@ -1132,7 +1132,7 @@ mod tests { let mut prog = run::Process::new("echo", [~"hello"], run::ProcessOptions::new()); let run::ProcessOutput {status, output, error} = prog.finish_with_output(); - let output_str = str::from_bytes(output); + let output_str = str::from_utf8(output); assert_eq!(status, 0); assert_eq!(output_str.trim().to_owned(), ~"hello"); @@ -1149,7 +1149,7 @@ mod tests { run::ProcessOptions::new()); let run::ProcessOutput {status, output, error} = prog.finish_with_output(); - let output_str = str::from_bytes(output); + let output_str = str::from_utf8(output); assert_eq!(status, 0); assert_eq!(output_str.trim().to_owned(), ~"hello"); @@ -1167,7 +1167,7 @@ mod tests { let run::ProcessOutput {status, output, error} = prog.finish_with_output(); - let output_str = str::from_bytes(output); + let output_str = str::from_utf8(output); assert_eq!(status, 0); assert_eq!(output_str.trim().to_owned(), ~"hello"); @@ -1195,7 +1195,7 @@ mod tests { let run::ProcessOutput {status, output, error} = prog.finish_with_output(); - let output_str = str::from_bytes(output); + let output_str = str::from_utf8(output); assert_eq!(status, 0); assert_eq!(output_str.trim().to_owned(), ~"hello"); @@ -1272,7 +1272,7 @@ mod tests { fn test_keep_current_working_dir() { let mut prog = run_pwd(None); - let output = str::from_bytes(prog.finish_with_output().output); + let output = str::from_utf8(prog.finish_with_output().output); let parent_dir = os::getcwd().normalize(); let child_dir = Path(output.trim()).normalize(); @@ -1290,7 +1290,7 @@ mod tests { let parent_dir = os::getcwd().dir_path().normalize(); let mut prog = run_pwd(Some(&parent_dir)); - let output = str::from_bytes(prog.finish_with_output().output); + let output = str::from_utf8(prog.finish_with_output().output); let child_dir = Path(output.trim()).normalize(); let parent_stat = parent_dir.stat().unwrap(); @@ -1329,7 +1329,7 @@ mod tests { if running_on_valgrind() { return; } let mut prog = run_env(None); - let output = str::from_bytes(prog.finish_with_output().output); + let output = str::from_utf8(prog.finish_with_output().output); let r = os::env(); for &(ref k, ref v) in r.iter() { @@ -1343,7 +1343,7 @@ mod tests { if running_on_valgrind() { return; } let mut prog = run_env(None); - let output = str::from_bytes(prog.finish_with_output().output); + let output = str::from_utf8(prog.finish_with_output().output); let r = os::env(); for &(ref k, ref v) in r.iter() { @@ -1362,7 +1362,7 @@ mod tests { new_env.push((~"RUN_TEST_NEW_ENV", ~"123")); let mut prog = run_env(Some(new_env)); - let output = str::from_bytes(prog.finish_with_output().output); + let output = str::from_utf8(prog.finish_with_output().output); assert!(output.contains("RUN_TEST_NEW_ENV=123")); } diff --git a/src/libstd/str.rs b/src/libstd/str.rs index d4f3c0aa3c7..9d718c30edb 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -55,13 +55,13 @@ Section: Creating a string /// # Failure /// /// Raises the `not_utf8` condition if invalid UTF-8 -pub fn from_bytes(vv: &[u8]) -> ~str { +pub fn from_utf8(vv: &[u8]) -> ~str { use str::not_utf8::cond; - match from_bytes_opt(vv) { + match from_utf8_opt(vv) { None => { let first_bad_byte = *vv.iter().find(|&b| !is_utf8([*b])).unwrap(); - cond.raise(fmt!("from_bytes: input is not UTF-8; first bad byte is %u", + cond.raise(fmt!("from_utf8: input is not UTF-8; first bad byte is %u", first_bad_byte as uint)) } Some(s) => s @@ -70,9 +70,9 @@ pub fn from_bytes(vv: &[u8]) -> ~str { /// Convert a vector of bytes to a new UTF-8 string, if possible. /// Returns None if the vector contains invalid UTF-8. -pub fn from_bytes_opt(vv: &[u8]) -> Option<~str> { +pub fn from_utf8_opt(vv: &[u8]) -> Option<~str> { if is_utf8(vv) { - Some(unsafe { raw::from_bytes(vv) }) + Some(unsafe { raw::from_utf8(vv) }) } else { None } @@ -83,23 +83,23 @@ pub fn from_bytes_opt(vv: &[u8]) -> Option<~str> { /// # Failure /// /// Raises the `not_utf8` condition if invalid UTF-8 -pub fn from_bytes_owned(vv: ~[u8]) -> ~str { +pub fn from_utf8_owned(vv: ~[u8]) -> ~str { use str::not_utf8::cond; if !is_utf8(vv) { let first_bad_byte = *vv.iter().find(|&b| !is_utf8([*b])).unwrap(); - cond.raise(fmt!("from_bytes: input is not UTF-8; first bad byte is %u", + cond.raise(fmt!("from_utf8: input is not UTF-8; first bad byte is %u", first_bad_byte as uint)) } else { - unsafe { raw::from_bytes_owned(vv) } + unsafe { raw::from_utf8_owned(vv) } } } /// Consumes a vector of bytes to create a new utf-8 string. /// Returns None if the vector contains invalid UTF-8. -pub fn from_bytes_owned_opt(vv: ~[u8]) -> Option<~str> { +pub fn from_utf8_owned_opt(vv: ~[u8]) -> Option<~str> { if is_utf8(vv) { - Some(unsafe { raw::from_bytes_owned(vv) }) + Some(unsafe { raw::from_utf8_owned(vv) }) } else { None } @@ -113,14 +113,14 @@ pub fn from_bytes_owned_opt(vv: ~[u8]) -> Option<~str> { /// # Failure /// /// Fails if invalid UTF-8 -pub fn from_bytes_slice<'a>(v: &'a [u8]) -> &'a str { - from_bytes_slice_opt(v).expect("from_bytes_slice: not utf-8") +pub fn from_utf8_slice<'a>(v: &'a [u8]) -> &'a str { + from_utf8_slice_opt(v).expect("from_utf8_slice: not utf-8") } /// Converts a vector to a string slice without performing any allocations. /// /// Returns None if the slice is not utf-8. -pub fn from_bytes_slice_opt<'a>(v: &'a [u8]) -> Option<&'a str> { +pub fn from_utf8_slice_opt<'a>(v: &'a [u8]) -> Option<&'a str> { if is_utf8(v) { Some(unsafe { cast::transmute(v) }) } else { None } @@ -1000,7 +1000,7 @@ pub mod raw { } /// Converts a vector of bytes to a new owned string. - pub unsafe fn from_bytes(v: &[u8]) -> ~str { + pub unsafe fn from_utf8(v: &[u8]) -> ~str { do v.as_imm_buf |buf, len| { from_buf_len(buf, len) } @@ -1009,12 +1009,12 @@ pub mod raw { /// Converts an owned vector of bytes to a new owned string. This assumes /// that the utf-8-ness of the vector has already been validated #[inline] - pub unsafe fn from_bytes_owned(v: ~[u8]) -> ~str { + pub unsafe fn from_utf8_owned(v: ~[u8]) -> ~str { cast::transmute(v) } /// Converts a byte to a string. - pub unsafe fn from_byte(u: u8) -> ~str { from_bytes([u]) } + pub unsafe fn from_byte(u: u8) -> ~str { from_utf8([u]) } /// Form a slice from a C string. Unsafe because the caller must ensure the /// C string has the static lifetime, or else the return value may be @@ -2975,14 +2975,14 @@ mod tests { } #[test] - fn test_unsafe_from_bytes() { + fn test_unsafe_from_utf8() { let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8]; - let b = unsafe { raw::from_bytes(a) }; + let b = unsafe { raw::from_utf8(a) }; assert_eq!(b, ~"AAAAAAA"); } #[test] - fn test_from_bytes() { + fn test_from_utf8() { let ss = ~"ศไทย中华Việt Nam"; let bb = ~[0xe0_u8, 0xb8_u8, 0xa8_u8, 0xe0_u8, 0xb9_u8, 0x84_u8, @@ -2996,9 +2996,9 @@ mod tests { 0x6d_u8]; - assert_eq!(ss, from_bytes(bb)); + assert_eq!(ss, from_utf8(bb)); assert_eq!(~"𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰", - from_bytes(bytes!("𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰"))); + from_utf8(bytes!("𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰"))); } #[test] @@ -3028,7 +3028,7 @@ mod tests { #[test] - fn test_from_bytes_fail() { + fn test_from_utf8_fail() { use str::not_utf8::cond; let bb = ~[0xff_u8, 0xb8_u8, 0xa8_u8, @@ -3044,11 +3044,11 @@ mod tests { let mut error_happened = false; let _x = do cond.trap(|err| { - assert_eq!(err, ~"from_bytes: input is not UTF-8; first bad byte is 255"); + assert_eq!(err, ~"from_utf8: input is not UTF-8; first bad byte is 255"); error_happened = true; ~"" }).inside { - from_bytes(bb) + from_utf8(bb) }; assert!(error_happened); } @@ -3133,7 +3133,7 @@ mod tests { let s1: ~str = ~"All mimsy were the borogoves"; let v: ~[u8] = s1.as_bytes().to_owned(); - let s2: ~str = from_bytes(v); + let s2: ~str = from_utf8(v); let mut i: uint = 0u; let n1: uint = s1.len(); let n2: uint = v.len(); @@ -3656,73 +3656,73 @@ mod tests { } #[test] - fn test_str_from_bytes_slice() { + fn test_str_from_utf8_slice() { let xs = bytes!("hello"); - assert_eq!(from_bytes_slice(xs), "hello"); + assert_eq!(from_utf8_slice(xs), "hello"); let xs = bytes!("ศไทย中华Việt Nam"); - assert_eq!(from_bytes_slice(xs), "ศไทย中华Việt Nam"); + assert_eq!(from_utf8_slice(xs), "ศไทย中华Việt Nam"); } #[test] #[should_fail] - fn test_str_from_bytes_slice_invalid() { + fn test_str_from_utf8_slice_invalid() { let xs = bytes!("hello", 0xff); - let _ = from_bytes_slice(xs); + let _ = from_utf8_slice(xs); } #[test] - fn test_str_from_bytes_slice_opt() { + fn test_str_from_utf8_slice_opt() { let xs = bytes!("hello"); - assert_eq!(from_bytes_slice_opt(xs), Some("hello")); + assert_eq!(from_utf8_slice_opt(xs), Some("hello")); let xs = bytes!("ศไทย中华Việt Nam"); - assert_eq!(from_bytes_slice_opt(xs), Some("ศไทย中华Việt Nam")); + assert_eq!(from_utf8_slice_opt(xs), Some("ศไทย中华Việt Nam")); let xs = bytes!("hello", 0xff); - assert_eq!(from_bytes_slice_opt(xs), None); + assert_eq!(from_utf8_slice_opt(xs), None); } #[test] - fn test_str_from_bytes() { + fn test_str_from_utf8() { let xs = bytes!("hello"); - assert_eq!(from_bytes(xs), ~"hello"); + assert_eq!(from_utf8(xs), ~"hello"); let xs = bytes!("ศไทย中华Việt Nam"); - assert_eq!(from_bytes(xs), ~"ศไทย中华Việt Nam"); + assert_eq!(from_utf8(xs), ~"ศไทย中华Việt Nam"); } #[test] - fn test_str_from_bytes_opt() { + fn test_str_from_utf8_opt() { let xs = bytes!("hello").to_owned(); - assert_eq!(from_bytes_opt(xs), Some(~"hello")); + assert_eq!(from_utf8_opt(xs), Some(~"hello")); let xs = bytes!("ศไทย中华Việt Nam"); - assert_eq!(from_bytes_opt(xs), Some(~"ศไทย中华Việt Nam")); + assert_eq!(from_utf8_opt(xs), Some(~"ศไทย中华Việt Nam")); let xs = bytes!("hello", 0xff); - assert_eq!(from_bytes_opt(xs), None); + assert_eq!(from_utf8_opt(xs), None); } #[test] - fn test_str_from_bytes_owned() { + fn test_str_from_utf8_owned() { let xs = bytes!("hello").to_owned(); - assert_eq!(from_bytes_owned(xs), ~"hello"); + assert_eq!(from_utf8_owned(xs), ~"hello"); let xs = bytes!("ศไทย中华Việt Nam").to_owned(); - assert_eq!(from_bytes_owned(xs), ~"ศไทย中华Việt Nam"); + assert_eq!(from_utf8_owned(xs), ~"ศไทย中华Việt Nam"); } #[test] - fn test_str_from_bytes_owned_opt() { + fn test_str_from_utf8_owned_opt() { let xs = bytes!("hello").to_owned(); - assert_eq!(from_bytes_owned_opt(xs), Some(~"hello")); + assert_eq!(from_utf8_owned_opt(xs), Some(~"hello")); let xs = bytes!("ศไทย中华Việt Nam").to_owned(); - assert_eq!(from_bytes_owned_opt(xs), Some(~"ศไทย中华Việt Nam")); + assert_eq!(from_utf8_owned_opt(xs), Some(~"ศไทย中华Việt Nam")); let xs = bytes!("hello", 0xff).to_owned(); - assert_eq!(from_bytes_owned_opt(xs), None); + assert_eq!(from_utf8_owned_opt(xs), None); } } diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs index cfc285488a9..c3a5afc1ec8 100644 --- a/src/libstd/sys.rs +++ b/src/libstd/sys.rs @@ -99,7 +99,7 @@ pub fn log_str<T>(t: &T) -> ~str { let mut result = io::mem::MemWriter::new(); repr::write_repr(&mut result as &mut io::Writer, t); - str::from_bytes_owned(result.inner()) + str::from_utf8_owned(result.inner()) } #[cfg(stage0)] pub fn log_str<T>(t: &T) -> ~str { |
