function booleanScalar(val) {
      if (typeof val === 'number') {
        return val !== 0;
      } else if (typeof val === 'boolean') {
        return val;
      } else if (typeof val === 'string') {
        return val.toLowerCase() === 'true';
      } else if (val instanceof Char) {
        // 1, T or t
        return val.code === 49 || val.code === 84 || val.code === 116;
      }
    }
Remove whitespace characters from the beginning and ending
of a String or a String array. Works like String.trim() but includes the
unicode nbsp character as well. If an array is passed in the function will return a new array not effecting the array passed in.

@param {String} str    the string to trim
@param {String[]} str  the string array to trim

@return {String|String[]} retrurns a string or an array will removed whitespaces