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


PHP CharsetConverter::specCharsToASCII方法代码示例

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


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

示例1: convertToSafeString

 /**
  * Converts a given string to a string that can be used as a URL segment.
  * The result is not url-encoded.
  *
  * @param string $string
  * @param string $spaceCharacter
  * @return string
  */
 public function convertToSafeString($string, $spaceCharacter = '-')
 {
     $processedTitle = $this->csConvertor->conv_case('utf-8', $string, 'toLower');
     $processedTitle = strip_tags($processedTitle);
     $processedTitle = preg_replace('/[ \\-+_]+/', $spaceCharacter, $processedTitle);
     $processedTitle = $this->csConvertor->specCharsToASCII('utf-8', $processedTitle);
     $processedTitle = preg_replace('/[^\\p{L}0-9' . preg_quote($spaceCharacter) . ']/u', '', $processedTitle);
     $processedTitle = preg_replace('/' . preg_quote($spaceCharacter) . '{2,}/', $spaceCharacter, $processedTitle);
     $processedTitle = trim($processedTitle, $spaceCharacter);
     // TODO Post-processing hook here
     $processedTitle = strtolower($processedTitle);
     return $processedTitle;
 }
开发者ID:MaxServ,项目名称:typo3-realurl,代码行数:21,代码来源:Utility.php

示例2: cleanFileName

 /**
  * Returns a string where any character not matching [.a-zA-Z0-9_-] is substituted by '_'
  * Trailing dots are removed
  *
  * @param string $fileName Input string, typically the body of a filename
  * @param string $charset Charset of the a filename (defaults to current charset; depending on context)
  * @return string Output string with any characters not matching [.a-zA-Z0-9_-] is substituted by '_' and trailing dots removed
  * @todo Deprecate, but still in use by the core
  * @deprecated but still in use in the Core. Don't use in your extensions!
  */
 public function cleanFileName($fileName, $charset = '')
 {
     // Handle UTF-8 characters
     if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
         // allow ".", "-", 0-9, a-z, A-Z and everything beyond U+C0 (latin capital letter a with grave)
         $cleanFileName = preg_replace('/[' . self::UNSAFE_FILENAME_CHARACTER_EXPRESSION . ']/u', '_', trim($fileName));
     } else {
         // Get conversion object or initialize if needed
         if (!is_object($this->csConvObj)) {
             $this->csConvObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Charset\CharsetConverter::class);
         }
         // Define character set
         if (!$charset) {
             if (TYPO3_MODE == 'FE') {
                 $charset = $GLOBALS['TSFE']->renderCharset;
             } else {
                 // Backend
                 $charset = 'utf-8';
             }
         }
         // If a charset was found, convert filename
         if ($charset) {
             $fileName = $this->csConvObj->specCharsToASCII($charset, $fileName);
         }
         // Replace unwanted characters by underscores
         $cleanFileName = preg_replace('/[' . self::UNSAFE_FILENAME_CHARACTER_EXPRESSION . '\\xC0-\\xFF]/', '_', trim($fileName));
     }
     // Strip trailing dots and return
     return rtrim($cleanFileName, '.');
 }
开发者ID:vip3out,项目名称:TYPO3.CMS,代码行数:40,代码来源:BasicFileUtility.php


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