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


PHP core_text::utf8ord方法代码示例

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


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

示例1: test_utf8ord

 /**
  * Tests the static utf8ord method.
  */
 public function test_utf8ord()
 {
     $this->assertSame(ord(''), core_text::utf8ord(''));
     $this->assertSame(ord('f'), core_text::utf8ord('f'));
     $this->assertSame(0x3b1, core_text::utf8ord('α'));
     $this->assertSame(0x439, core_text::utf8ord('й'));
     $this->assertSame(0x2fa1f, core_text::utf8ord('𯨟'));
     $this->assertSame(381, core_text::utf8ord('Ž'));
 }
开发者ID:rushi963,项目名称:moodle,代码行数:12,代码来源:text_test.php

示例2: obfuscate_text

/**
 * This function takes some text and replaces about half of the characters
 * with HTML entity equivalents.   Return string is obviously longer.
 *
 * @param string $plaintext The text to be obfuscated
 * @return string The obfuscated text
 */
function obfuscate_text($plaintext)
{
    $i = 0;
    $length = core_text::strlen($plaintext);
    $obfuscated = '';
    $prevobfuscated = false;
    while ($i < $length) {
        $char = core_text::substr($plaintext, $i, 1);
        $ord = core_text::utf8ord($char);
        $numerical = $ord >= ord('0') && $ord <= ord('9');
        if ($prevobfuscated and $numerical) {
            $obfuscated .= '&#' . $ord . ';';
        } else {
            if (rand(0, 2)) {
                $obfuscated .= '&#' . $ord . ';';
                $prevobfuscated = true;
            } else {
                $obfuscated .= $char;
                $prevobfuscated = false;
            }
        }
        $i++;
    }
    return $obfuscated;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:32,代码来源:weblib.php

示例3: yy_advance

 protected function yy_advance()
 {
     if ($this->yy_buffer_index < $this->yy_buffer_read) {
         $char = $this->yy_buffer[$this->yy_buffer_index++];
         return core_text::utf8ord($char);
     }
     if ($this->yy_buffer_start != 0) {
         // Shunt.
         $j = $this->yy_buffer_read - $this->yy_buffer_start;
         $this->yy_buffer = $this->yy_buffer->substring($this->yy_buffer_start, $j);
         $this->yy_buffer_end -= $this->yy_buffer_start;
         $this->yy_buffer_start = 0;
         $this->yy_buffer_read = $j;
         $this->yy_buffer_index = $j;
         $data = fread($this->yy_reader, 8192);
         if ($data === false || !core_text::strlen($data)) {
             return $this->YY_EOF;
         }
         $this->yy_buffer->concatenate($data);
         $this->yy_buffer_read += core_text::strlen($data);
     }
     while ($this->yy_buffer_index >= $this->yy_buffer_read) {
         $data = fread($this->yy_reader, 8192);
         if ($data === false || !core_text::strlen($data)) {
             return $this->YY_EOF;
         }
         $this->yy_buffer->concatenate($data);
         $this->yy_buffer_read += core_text::strlen($data);
     }
     $char = $this->yy_buffer[$this->yy_buffer_index++];
     return core_text::utf8ord($char);
 }
开发者ID:saylordotorg,项目名称:moodle-qtype_poasquestion,代码行数:32,代码来源:jlex.php


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