本文整理汇总了PHP中TYPO3\CMS\Core\Charset\CharsetConverter::utf8CharToUnumber方法的典型用法代码示例。如果您正苦于以下问题:PHP CharsetConverter::utf8CharToUnumber方法的具体用法?PHP CharsetConverter::utf8CharToUnumber怎么用?PHP CharsetConverter::utf8CharToUnumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Charset\CharsetConverter
的用法示例。
在下文中一共展示了CharsetConverter::utf8CharToUnumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: encodeCharacter
/**
* Returns backslash encoded numeric format. Does not use backslash
* character escapes such as, \" or \' as these may cause parsing problems.
* For example, if a javascript attribute, such as onmouseover, contains
* a \" that will close the entire attribute and allow an attacker to inject
* another script attribute.
*
* @param string $character utf-8 character that needs to be encoded
* @return string encoded character
*/
protected function encodeCharacter($character)
{
if ($this->isImmuneCharacter($character)) {
return $character;
}
$ordinalValue = $this->charsetConversion->utf8CharToUnumber($character);
// Check for alphanumeric characters
$hex = $this->getHexForNonAlphanumeric($ordinalValue);
if ($hex === NULL) {
return $character;
}
// Encode up to 256 with \\xHH
if ($ordinalValue < 256) {
$pad = substr('00', strlen($hex));
return '\\x' . $pad . strtoupper($hex);
}
// Otherwise encode with \\uHHHH
$pad = substr('0000', strlen($hex));
return '\\u' . $pad . strtoupper($hex);
}
示例2: splitString
/**
* Splitting a string for ImageTTFBBox up into an array where each part has its own configuration options.
*
* @param string $string UTF-8 string
* @param array $splitRendering Split-rendering configuration from GIFBUILDER TEXT object.
* @param int $fontSize Current fontsize
* @param string $fontFile Current font file
* @return array Array with input string splitted according to configuration
*/
public function splitString($string, $splitRendering, $fontSize, $fontFile)
{
// Initialize by setting the whole string and default configuration as the first entry.
$result = array();
$result[] = array('str' => $string, 'fontSize' => $fontSize, 'fontFile' => $fontFile);
// Traverse the split-rendering configuration:
// Splitting will create more entries in $result with individual configurations.
if (is_array($splitRendering)) {
$sKeyArray = TemplateService::sortedKeyList($splitRendering);
// Traverse configured options:
foreach ($sKeyArray as $key) {
$cfg = $splitRendering[$key . '.'];
// Process each type of split rendering keyword:
switch ((string) $splitRendering[$key]) {
case 'highlightWord':
if ((string) $cfg['value'] !== '') {
$newResult = array();
// Traverse the current parts of the result array:
foreach ($result as $part) {
// Explode the string value by the word value to highlight:
$explodedParts = explode($cfg['value'], $part['str']);
foreach ($explodedParts as $c => $expValue) {
if ((string) $expValue !== '') {
$newResult[] = array_merge($part, array('str' => $expValue));
}
if ($c + 1 < count($explodedParts)) {
$newResult[] = array('str' => $cfg['value'], 'fontSize' => $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'], 'fontFile' => $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'], 'color' => $cfg['color'], 'xSpaceBefore' => $cfg['xSpaceBefore'], 'xSpaceAfter' => $cfg['xSpaceAfter'], 'ySpaceBefore' => $cfg['ySpaceBefore'], 'ySpaceAfter' => $cfg['ySpaceAfter']);
}
}
}
// Set the new result as result array:
if (!empty($newResult)) {
$result = $newResult;
}
}
break;
case 'charRange':
if ((string) $cfg['value'] !== '') {
// Initialize range:
$ranges = GeneralUtility::trimExplode(',', $cfg['value'], true);
foreach ($ranges as $i => $rangeDef) {
$ranges[$i] = GeneralUtility::intExplode('-', $ranges[$i]);
if (!isset($ranges[$i][1])) {
$ranges[$i][1] = $ranges[$i][0];
}
}
$newResult = array();
// Traverse the current parts of the result array:
foreach ($result as $part) {
// Initialize:
$currentState = -1;
$bankAccum = '';
// Explode the string value by the word value to highlight:
$utf8Chars = $this->csConvObj->utf8_to_numberarray($part['str'], true, true);
foreach ($utf8Chars as $utfChar) {
// Find number and evaluate position:
$uNumber = (int) $this->csConvObj->utf8CharToUnumber($utfChar);
$inRange = 0;
foreach ($ranges as $rangeDef) {
if ($uNumber >= $rangeDef[0] && (!$rangeDef[1] || $uNumber <= $rangeDef[1])) {
$inRange = 1;
break;
}
}
if ($currentState == -1) {
$currentState = $inRange;
}
// Initialize first char
// Switch bank:
if ($inRange != $currentState && $uNumber !== 9 && $uNumber !== 10 && $uNumber !== 13 && $uNumber !== 32) {
// Set result:
if ($bankAccum !== '') {
$newResult[] = array('str' => $bankAccum, 'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'], 'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'], 'color' => $currentState ? $cfg['color'] : '', 'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '', 'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '', 'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '', 'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : '');
}
// Initialize new settings:
$currentState = $inRange;
$bankAccum = '';
}
// Add char to bank:
$bankAccum .= $utfChar;
}
// Set result for FINAL part:
if ($bankAccum !== '') {
$newResult[] = array('str' => $bankAccum, 'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'], 'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'], 'color' => $currentState ? $cfg['color'] : '', 'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '', 'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '', 'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '', 'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : '');
}
}
// Set the new result as result array:
if (!empty($newResult)) {
$result = $newResult;
}
}
//.........这里部分代码省略.........