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


PHP Utf8::ord方法代码示例

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


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

示例1: encodeEmail

 /**
  * Encode all e-mail addresses within a string
  *
  * @param string $strString The string to encode
  *
  * @return string The encoded string
  */
 public static function encodeEmail($strString)
 {
     foreach (static::extractEmail($strString) as $strEmail) {
         $strEncoded = '';
         $arrCharacters = Utf8::str_split($strEmail);
         foreach ($arrCharacters as $strCharacter) {
             $strEncoded .= sprintf(rand(0, 1) ? '&#x%X;' : '&#%s;', Utf8::ord($strCharacter));
         }
         $strString = str_replace($strEmail, $strEncoded, $strString);
     }
     return str_replace('mailto:', 'mailto:', $strString);
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:19,代码来源:StringUtil.php

示例2: api_ord

/**
 * Takes the first character in a string and returns its Unicode codepoint.
 * @param string $character				The input string.
 * @param string $encoding (optional)	The encoding of the input string. If it is omitted, the platform character set will be used by default.
 * @return int							Returns: the codepoint of the first character; or 0xFFFD (unknown character) when the input string is empty.
 * This is a multibyte aware version of the function ord().
 * @link http://php.net/manual/en/function.ord.php
 * Note the difference with the original funtion ord(): ord('') returns 0, api_ord('') returns 0xFFFD (unknown character).
 */
function api_ord($character, $encoding)
{
    return Patchwork\Utf8::ord(api_utf8_encode($character, $encoding));
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:13,代码来源:internationalization.lib.php

示例3: testChrOrd

 /**
  * @covers Patchwork\Utf8::chr
  * @covers Patchwork\Utf8::ord
  */
 function testChrOrd()
 {
     foreach (self::$utf8ValidityMap as $u => $t) {
         if ($t) {
             $this->assertSame($u, u::chr(u::ord($u)));
         }
     }
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:12,代码来源:Utf8Test.php

示例4: fillRange

 /**
  *  Fill a range given starting and ending character
  *
  *  @return void
  *  @access public
  */
 public function fillRange(Scope $head, $start, $end)
 {
     $start_index = Utf8::ord($start);
     $ending_index = Utf8::ord($end);
     if ($ending_index < $start_index) {
         throw new ParserException(sprintf('Character class range %s - %s is out of order', $start, $end));
     }
     for ($i = $start_index; $i <= $ending_index; $i++) {
         $head->setLiteral($i, Utf8::chr($i));
     }
 }
开发者ID:JellePhoneGap,项目名称:ReverseRegex,代码行数:17,代码来源:CharacterClass.php

示例5: utf8_ord

/**
 * Return the ASCII value of a character
 *
 * Unicode version of ord() that handles UTF-8 characters.
 *
 * @param string $str
 *
 * @return integer
 *
 * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
 *             Use Patchwork\Utf8::ord() instead.
 */
function utf8_ord($str)
{
    @trigger_error('Using utf8_ord() has been deprecated and will no longer work in Contao 5.0. Use Patchwork\\Utf8::ord() instead.', E_USER_DEPRECATED);
    return Utf8::ord($str);
}
开发者ID:contao,项目名称:core-bundle,代码行数:17,代码来源:functions.php

示例6: getQuestion

 /**
  * Generate the captcha question
  *
  * @return string The question string
  */
 protected function getQuestion()
 {
     $int1 = rand(1, 9);
     $int2 = rand(1, 9);
     $question = $GLOBALS['TL_LANG']['SEC']['question' . rand(1, 3)];
     $question = sprintf($question, $int1, $int2);
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     $objSession->set('captcha_' . $this->strId, array('sum' => $int1 + $int2, 'key' => $this->strCaptchaKey, 'time' => time()));
     $strEncoded = '';
     $arrCharacters = Utf8::str_split($question);
     foreach ($arrCharacters as $strCharacter) {
         $strEncoded .= sprintf('&#%s;', Utf8::ord($strCharacter));
     }
     return $strEncoded;
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:21,代码来源:FormCaptcha.php

示例7: test_4_byte_char

 public function test_4_byte_char()
 {
     $str = "𐌼";
     $this->assertEquals(66364, u::ord($str));
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:5,代码来源:Utf8OrdTest.php

示例8: encodeEmail

 /**
  * Encode all e-mail addresses within a string
  *
  * @param string $strString The string to encode
  *
  * @return string The encoded string
  */
 public static function encodeEmail($strString)
 {
     if (strpos($strString, '@') === false) {
         return $strString;
     }
     $arrEmails = static::extractEmail($strString, \Config::get('allowedTags'));
     foreach ($arrEmails as $strEmail) {
         $strEncoded = '';
         $arrCharacters = Utf8::str_split($strEmail);
         foreach ($arrCharacters as $strCharacter) {
             $strEncoded .= sprintf(rand(0, 1) ? '&#x%X;' : '&#%s;', Utf8::ord($strCharacter));
         }
         $strString = str_replace($strEmail, $strEncoded, $strString);
     }
     return str_replace('mailto:', '&#109;&#97;&#105;&#108;&#116;&#111;&#58;', $strString);
 }
开发者ID:contao,项目名称:core-bundle,代码行数:23,代码来源:StringUtil.php


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