當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。