Translates char list into keystroke sequence.

@param mixed $charList
@return array
@throws WebDriver_Exception
6805
public static function prepareKeyStrokes($charList)
    {
        $keyStrokes = [];
        foreach ((array) $charList as $char) {
            if (is_int($char)) {
                // treat int as 16-bit little-endian Unicode
                if (false === $symbol = iconv('UTF-16LE', 'UTF-8', pack('v', $char))) {
                    throw new WebDriver_UtilException("Invalid Unicode symbol: U+" . strtoupper(dechex($char)));
                }
                $keyStrokes[] = $symbol;
            } else {
                $keyStrokes[] = (string) $char;
            }
        }
        if (empty($keyStrokes)) {
            throw new WebDriver_UtilException("No keystrokes to send");
        }
        return $keyStrokes;
    }
1120490
private function findTableChars(string $line) : ?array
    {
        $lineChar  = $line[0];
        $spaceChar = null;

        for ($i = 0; $i < strlen($line); $i++) {
            if ($line[$i] === $lineChar) {
                continue;
            }

            if ($spaceChar === null) {
                $spaceChar = $line[$i];

                continue;
            }

            if ($line[$i] !== $spaceChar) {
                return null;
            }
        }

        if ($spaceChar === null) {
            return null;
        }

        return [$lineChar, $spaceChar];
    }
604674
public static function GetCharsetMapForMimeType () {
		return [
			Encoding::UTF_8		=> static::CHARSET_UTF_8,
			Encoding::EUC_JP	=> static::CHARSET_EUC_JP,
			Encoding::SJIS		=> static::CHARSET_SHIFT_JIS,
			Encoding::SJIS_WIN	=> static::CHARSET_SHIFT_JIS,
		];
	}
40046
protected function _asText($shellList)
    {
        foreach ($shellList as $plugin => $commands) {
            sort($commands);
            $this->out(sprintf('[<info>%s</info>] %s', $plugin, implode(', ', $commands)));
            $this->out();
        }

        $this->out('To run an app or core command, type <info>`cake shell_name [args]`</info>');
        $this->out('To run a plugin command, type <info>`cake Plugin.shell_name [args]`</info>');
        $this->out('To get help on a specific command, type <info>`cake shell_name --help`</info>', 2);
    }
1148103
protected function getPossibleKeys()
	{
		$keys = [];
		foreach (range('a', 'z') as $char)
		{
			$keys[] = $this->keyPrefix . $char;
		}

		return $keys;
	}
109694
public static function random($charLists = null, $length = 32)
    {
        if (!$charLists) {
            $charLists = static::ALNUM;
        }

        $string   = '';
        $poolSize = mb_strlen($charLists) - 1;

        for ($i = 0; $i < $length; $i++) {
            $string .= mb_substr($charLists, mt_rand(0, $poolSize), 1);
        }

        return $string;
    }
764940
private function escapeSpecialCharacters($line)
    {
        $line = $this->escapeFirstCharacters($line);

        $line = $this->escapeOtherCharacters($line);

        return $this->escapeOtherCharactersRegex($line);
    }
617445
protected function createRegex()
    {
        // Load list from driver
        if (empty($list = $this->getDriver()->getList())) {
            return null;
        }

        return sprintf('/\b(%s)\b/i', implode('|', array_map(function ($value) {
            if (isset($value[0]) && $value[0] == '[') {
                return $value;
            }
            else if (preg_match("/\r\n|\r|\n/", $value)) {
                return preg_replace("/\r\n|\r|\n/", "|", $value);
            }

            return preg_quote($value);

        }, $list)));
    }
1351415
public function trim($string, $charlist = null)
    {
        $string = (string)$string;

        if ($charlist === null) {
            return trim($string);
        } else {
            return trim($string, $charlist);
        }
    }
1165624
public function trim($charlist = null, $ends = null)
    {
        switch (true) {
            case is_null($charlist) && ($ends == self::BOTH || is_null($ends)):
                $this->setInternalValue(trim($this->getInternalValue()));
                break;

            case is_null($ends) || $ends == self::BOTH:
                $this->setInternalValue(trim($this->getInternalValue(), $charlist));
                break;

            case !is_null($ends):
                switch (true) {
                    case $ends == self::LEFT:
                        $callback = 'ltrim';
                        break;

                    case $ends == self::RIGHT:
                        $callback = 'rtrim';
                        break;
                }

                if (is_null($charlist)) {
                    $this->setInternalValue(call_user_func($callback, $this->getInternalValue()));
                } else {
                    $this->setInternalValue(call_user_func($callback, $this->getInternalValue(), $charlist));
                }

                break;

        }

        return $this;

    }
678913
public function getCharacterList($charName, $page = 1)
    {
        $characterList = $this->gameDataService->getCharacterList($charName);

        return $this->getPaginator4QueryBuilder($characterList, $page);
    }
638154
private function printList($list)
    {
        $result = "";
        $comma = 0;
        for ($i = 0, $_i = count($list); $i < $_i; $i++) {
            $col = $list[$i];
            if ($col->isPrimaryKey()) {
                $result .= ($comma++ ? ',' : '') . $this->getDatabase()->getPlatform()->quoteIdentifier($col->getName());
            }
        }

        return $result;
    }
962161
public function trimLeft($charlist = null)
    {
        return $this->cloneInstance(
            function (StringObject $new) use ($charlist) {
                $new->string = Mbstring::ltrim($new->string, $charlist);
            }
        );
    }
120012
public function getStateList($list = null) {
		$result = '';
		if (empty($list)) {
			return $result;
		}

		$listText = '';
		foreach ($list as $listItem) {
			$classItem = '';
			if (is_array($listItem)) {
				if (!isset($listItem['textItem'])) {
					continue;
				}

				$textItem = $listItem['textItem'];
				if (isset($listItem['classItem']) && !empty($listItem['classItem'])) {
					$classItem = ' ' . $listItem['classItem'];
				}
			} else {
				$textItem = $listItem;
			}

			$listText .= $this->Html->tag('li', $textItem, ['class' => 'list-group-item' . $classItem]);
		}
		if (empty($listText)) {
			return $result;
		}

		$result = $this->Html->tag('ul', $listText, ['class' => 'list-group']);

		return $result;
	}
1284436
public function getCharsets()
    {
        if (null !== $this->charsets) {
            return $this->charsets;
        }

        return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all());
    }
430652
public function pressKey($char, $field)
    {
        static $keys = array(
        'backspace' => 8,
        'tab' => 9,
        'enter' => 13,
        'shift' => 16,
        'ctrl' =>  17,
        'alt' => 18,
        'pause' => 19,
        'break' => 19,
        'escape' =>  27,
        'esc' =>  27,
        'end' => 35,
        'home' =>  36,
        'left' => 37,
        'up' => 38,
        'right' =>39,
        'down' => 40,
        'insert' =>  45,
        'delete' =>  46,
        'pageup' => 33,
        'pagedown' => 34,
        'capslock' => 20,
        );

        if (is_string($char)) {
            if (strlen($char) < 1) {
                throw new \Exception('FeatureContext->keyPress($char, $field) was invoked but the $char parameter was empty.');
            } elseif (strlen($char) > 1) {
                // Support for all variations, e.g. ESC, Esc, page up, pageup.
                $char = $keys[strtolower(str_replace(' ', '', $char))];
            }
        }

        $element = $this->getSession()->getPage()->findField($field);
        if (!$element) {
            throw new \Exception("Field '$field' not found");
        }

        $driver = $this->getSession()->getDriver();
        // $driver->keyPress($element->getXpath(), $char);
        // This alternative to Driver->keyPress() handles cases that depend on
        // javascript which binds to key down/up events directly, such as Drupal's
        // autocomplete.js.
        $driver->keyDown($element->getXpath(), $char);
        $driver->keyUp($element->getXpath(), $char);
    }
856527
protected function parseConditionList($conditionList)
    {
        $charset = $this->getCharset();

        $conditions = [];
        foreach (Condition::splitNestedConditions($conditionList) as $normalizedConditionList) {
            $normalizedConditions = [];
            $currentCondition = "";

            if (preg_match('/[^\x00-\x7f]/', $normalizedConditionList)) {
                $isAscii = false;
                $strLen  = mb_strlen($normalizedConditionList, $charset);
                $getAnd  = function($i) use ($normalizedConditionList){return strtolower(substr($normalizedConditionList, $i, 5));};
            } else {
                $isAscii = true;
                $strLen = strlen($normalizedConditionList);
                $getAnd  = function($i) use ($charset, $normalizedConditionList){return mb_strtolower(mb_substr($normalizedConditionList, $i, 5, $charset), $charset);};
            }

            for ($i = 0, $j = $strLen; $i < $j; $i++) {
                if ($isAscii === true) {
                    //$char = substr($normalizedConditionList, $i, 1);
                    $char = $normalizedConditionList[$i];
                } else {
                    $char = mb_substr($normalizedConditionList, $i, 1, $charset);
                }

                if ($char === " " && $getAnd($i) === " and ") {
                    $normalizedConditions[] = new MediaCondition(trim($currentCondition, " \r\n\t\f"));
                    $currentCondition = "";
                    $i += (5 - 1);
                } else {
                    $currentCondition .= $char;
                }
            }
            $currentCondition = trim($currentCondition, " \r\n\t\f");
            if ($currentCondition !== "") {
                $normalizedConditions[] = new MediaCondition(trim($currentCondition, " \r\n\t\f"));
            }

            foreach ($normalizedConditions as $normalizedCondition) {
                $conditions[] = $normalizedCondition;
            }
        }

        return $conditions;
    }