本文整理汇总了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);
}
示例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));
}
示例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)));
}
}
}
示例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));
}
}
示例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);
}
示例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;
}
示例7: test_4_byte_char
public function test_4_byte_char()
{
$str = "𐌼";
$this->assertEquals(66364, u::ord($str));
}
示例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:', 'mailto:', $strString);
}