Function roe::to_ascii_uppercase
source · pub fn to_ascii_uppercase<T: AsRef<[u8]>>(slice: T) -> Vec<u8>
Available on crate feature
alloc
only.Expand description
Returns a vector containing a copy of the given slice where each byte is mapped to its ASCII upper case equivalent.
ASCII letters ‘a’ to ‘z’ are mapped to ‘A’ to ‘Z’, but non-ASCII letters are unchanged.
This function can be used to implement String#upcase
and
Symbol#upcase
for ASCII strings in Ruby.
To uppercase the value in-place, use make_ascii_uppercase
. This function
is analogous to <[u8]>::to_ascii_uppercase
.
Examples
assert_eq!(to_ascii_uppercase("ABCxyz"), &b"ABCXYZ"[..]);
assert_eq!(to_ascii_uppercase("1234%&*"), &b"1234%&*"[..]);