0

ToUpper or ToLower functionality in mu

Is there a mu  function for changing all the chars in a string to uppercase and lowercase

1 comment

  • 0
    Avatar
    Alan Trombla

    Hi Ahson,

    There are no built-in Mu functions for this.  But here are simple (ASCII) implementations in Mu:

        function: toLower (string mixed)
        {
            let ret = "",
                diff = 'a' - 'A';

            for (int i = 0; i < mixed.size(); ++i)
            {
                let c = mixed[i];
                ret += if (c >= 'A' && c <= 'Z') then (c + diff) else c;
            }

            return ret;
        }

        function: toUpper (string mixed)
        {
            let ret = "",
                diff = 'a' - 'A';

            for (int i = 0; i < mixed.size(); ++i)
            {
                let c = mixed[i];
                ret += if (c >= 'a' && c <= 'z') then (c - diff) else c;
            }

            return ret;
        }

     

    Hope that helps,

    Alan

Please sign in to leave a comment.