Motoko Type Text methods uppercase and lowercase

From many high-level languages, there are methods to convert uppercase and lowercase for the processing of text String type, but I did not see any processing about this in motoko. Regarding this method, because there is no guarantee that all the data transmitted at the front desk is the same Scenarios where business needs are consistent. I think it is still very necessary in business scenarios.

I don’t know if the official will add this method in a later version?

1 Like

For the moment you can do this:

import Text "mo:base/Text";
import Prim "mo:prim";

let message = "HeLLo";

let x = Text.map(message , Prim.charToLower);
let y = Text.map(message , Prim.charToUpper);

Note you generally shouldn’t use this Prim import (it’s internal and subject to change) but those functions aren’t yet exposed in the base library, I’m sure they will be soon.

8 Likes

Has anyone come up with a different solution for this?
Is there any progress on getting this into the base library?