public static function toBool(string $str, string $encoding = null) : bool
    {
        static $map = [
            'true'  => true,
            'false' => false,
            '1'     => true,
            '0'     => false,
            'on'    => true,
            'off'   => false,
            'yes'   => true,
            'no'    => false,
            'y'     => true,
            'n'     => false
        ];

        $encoding = $encoding ?: static::encoding($str);

        return $map[mb_strtolower($str, $encoding)] ?? (bool) static::replace($str, '[[:space:]]', '', 'msr', $encoding);
    }