types.String.toupper
stringReturns a copy of str with the ASCII letters in [start, end) uppercased.
... from the prose below, not from the signature.Parameters
start | number | index of the first byte to convert; defaults to 0 optional |
end | number | index one past the last byte to convert; defaults to str.len() optional |
... | any | not a real parameter; see Notes repeats |
Return value
A copy of str the same length as the original, with every byte in [start, end) that is a-z replaced by its uppercase letter. Bytes outside the range, and bytes inside it that are not a-z (including any byte of a multi-byte character), are copied unchanged. With no arguments the whole string is uppercased.
Errors
Throws wrong indexes when end < start after negative indices are resolved (see types.String.tolower). Throws slice out of range when end > str.len() or the resolved start < 0.
Notes
Takes 0, 1 or 2 arguments, not the variadic tail the VM's dump implies. See the Notes on types.String.tolower for why an out-of-range range throws here but clamps for types.String.slice, and for the ASCII-only scope of the conversion.
Example
println("\"abc\".toupper() =", "abc".toupper())
println("\"abcdef\".toupper(1, 3) =", "abcdef".toupper(1, 3))
// non-ASCII bytes are never touched.
let mb = "\xD0\x9F\xD0\xBE"
println("mb.toupper() == mb =", mb.toupper() == mb)"abc".toupper() = ABC
"abcdef".toupper(1, 3) = aBCdef
mb.toupper() == mb = trueSee also
tolower | Returns a copy of str with the ASCII letters in [start, end) lowercased. |
slice | Returns the bytes of str from start up to, but not including, end. |
| string | class index |