当前位置: 首页>>代码示例>>PHP>>正文


PHP CharsetConverter::utf8_to_numberarray方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Charset\CharsetConverter::utf8_to_numberarray方法的典型用法代码示例。如果您正苦于以下问题:PHP CharsetConverter::utf8_to_numberarray方法的具体用法?PHP CharsetConverter::utf8_to_numberarray怎么用?PHP CharsetConverter::utf8_to_numberarray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Charset\CharsetConverter的用法示例。


在下文中一共展示了CharsetConverter::utf8_to_numberarray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: JScharCode

 /**
  * Converts the input string to a JavaScript function returning the same string, but charset-safe.
  * Used for confirm and alert boxes where we must make sure that any string content
  * does not break the script AND want to make sure the charset is preserved.
  * Originally I used the JS function unescape() in combination with PHP function
  * rawurlencode() in order to pass strings in a safe way. This could still be done
  * for iso-8859-1 charsets but now I have applied the same method here for all charsets.
  *
  * @param string $str Input string, encoded with UTF-8
  * @return string Output string, a JavaScript function: "String.fromCharCode(......)
  * @depreacted since 6.2 - will be removed two versions later; use GeneralUtility::quoteJSvalue() instead
  */
 public function JScharCode($str)
 {
     GeneralUtility::logDeprecatedFunction();
     // Convert the UTF-8 string into a array of char numbers:
     $nArr = $this->csConvObj->utf8_to_numberarray($str);
     return 'String.fromCharCode(' . implode(',', $nArr) . ')';
 }
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:19,代码来源:LanguageService.php

示例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;
                         }
                     }
//.........这里部分代码省略.........
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:101,代码来源:GraphicalFunctions.php

示例3: singleChars

 /**
  * Split a string into an array of individual characters
  * The function will look at $this->nativeCharset and if that is set, the input string is expected to be UTF-8 encoded, possibly with entities in it. Otherwise the string is supposed to be a single-byte charset which is just splitted by a for-loop.
  *
  * @param string $theText The text string to split
  * @param bool $returnUnicodeNumber Return Unicode numbers instead of chars.
  * @return array Numerical array with a char as each value.
  */
 public function singleChars($theText, $returnUnicodeNumber = FALSE)
 {
     if ($this->nativeCharset) {
         // Get an array of separated UTF-8 chars
         return $this->csConvObj->utf8_to_numberarray($theText, 1, $returnUnicodeNumber ? 0 : 1);
     } else {
         $output = array();
         $c = strlen($theText);
         for ($a = 0; $a < $c; $a++) {
             $output[] = substr($theText, $a, 1);
         }
         return $output;
     }
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:22,代码来源:GraphicalFunctions.php

示例4: JScharCode

 /**
  * Converts the input string to a JavaScript function returning the same string, but charset-safe.
  * Used for confirm and alert boxes where we must make sure that any string content
  * does not break the script AND want to make sure the charset is preserved.
  * Originally I used the JS function unescape() in combination with PHP function
  * rawurlencode() in order to pass strings in a safe way. This could still be done
  * for iso-8859-1 charsets but now I have applied the same method here for all charsets.
  *
  * @param string $str Input string, encoded with UTF-8
  * @return string Output string, a JavaScript function: "String.fromCharCode(......)
  */
 public function JScharCode($str)
 {
     // Convert the UTF-8 string into a array of char numbers:
     $nArr = $this->csConvObj->utf8_to_numberarray($str);
     return 'String.fromCharCode(' . implode(',', $nArr) . ')';
 }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:17,代码来源:LanguageService.php


注:本文中的TYPO3\CMS\Core\Charset\CharsetConverter::utf8_to_numberarray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。