Re: [PATCH] rust: str: add to_ascii_{upper,lower}case() to CString

From: Greg KH
Date: Mon Jan 22 2024 - 14:42:32 EST


On Mon, Jan 22, 2024 at 07:45:57PM +0100, Danilo Krummrich wrote:
> Add functions to convert a CString to upper- / lowercase assuming all
> characters are ASCII encoded.
>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> ---
> rust/kernel/str.rs | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
> index 7d848b83add4..d21151d89861 100644
> --- a/rust/kernel/str.rs
> +++ b/rust/kernel/str.rs
> @@ -581,6 +581,16 @@ pub fn try_from_fmt(args: fmt::Arguments<'_>) -> Result<Self, Error> {
> // exist in the buffer.
> Ok(Self { buf })
> }
> +
> + /// Converts the whole CString to lowercase.
> + pub fn to_ascii_lowercase(&mut self) {
> + self.buf.make_ascii_lowercase();
> + }
> +
> + /// Converts the whole CString to uppercase.
> + pub fn to_ascii_uppercase(&mut self) {
> + self.buf.make_ascii_uppercase();
> + }

How are you handling locales?

thanks,

greg k-h