• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Normalizer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Normalizer的典型用法代码示例。如果您正苦于以下问题:PHP Normalizer类的具体用法?PHP Normalizer怎么用?PHP Normalizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: __construct

 /**
  * Class constructor.
  *
  * @param mixed $string
  * @param string $encoding
  * @throws \InvalidArgumentException
  */
 public function __construct($string, $encoding = self::ENCODING)
 {
     if (is_null($string)) {
         $string = 'null';
     } elseif (is_bool($string)) {
         $string = $string ? 'true' : 'false';
     } elseif (is_int($string) || is_float($string)) {
         $string = (string) $string;
     } elseif (is_object($string)) {
         if (!method_exists($string, '__toString')) {
             throw new \InvalidArgumentException(sprintf('Object of class %s cannot be converted to String', get_class($string)));
         }
         $string = (string) $string;
     } elseif (!is_string($string)) {
         throw new \InvalidArgumentException('Cannot convert a variable of type ' . gettype($string) . ' to String');
     }
     if (!self::checkEncoding($encoding)) {
         throw new \InvalidArgumentException('Unsupported encoding: ' . $encoding);
     }
     if (!mb_check_encoding($string, $encoding)) {
         throw new \InvalidArgumentException('String is not encoded in ' . $encoding);
     }
     if ($encoding != self::ENCODING) {
         $string = mb_convert_encoding($string, self::ENCODING, $encoding);
     }
     $string = \Normalizer::normalize($string);
     $this->string = $string;
     $this->length = mb_strlen($string, self::ENCODING);
 }
开发者ID:e-ruiz,项目名称:brick,代码行数:36,代码来源:String.php


示例2: message

 public static function message($publishHandler, eZContentObject $object, $message, $messageLength = null, $options)
 {
     $url = false;
     if (isset($options['include_url']) && (bool) $options['include_url'] === true) {
         $url = $object->attribute('main_node')->attribute('url_alias');
         eZURI::transformURI($url, true, 'full');
         if (isset($options['shorten_url']) && (bool) $options['shorten_url'] === true) {
             $urlReturned = $publishHandler->shorten($url, $options['shorten_handler']);
             if (is_string($urlReturned)) {
                 $url = $urlReturned;
             }
         }
         if ($messageLength != null) {
             $messageLength = $messageLength - strlen($url) - 1;
         }
     }
     if (class_exists('Normalizer')) {
         $message = Normalizer::normalize($message, Normalizer::FORM_C);
     }
     if ($messageLength != null) {
         $message = mb_substr($message, 0, $messageLength);
     }
     if ($url) {
         $message .= ' ' . $url;
     }
     return $message;
 }
开发者ID:sdaoudi,项目名称:nxc_social_networks,代码行数:27,代码来源:nxcSocialNetworksMessageHandlerDefault.php


示例3: applyValue

 protected function applyValue($input, Context $ctx)
 {
     $output = $input;
     if ($input === null || $input === true || $input === false) {
         goto done;
     }
     if ($this->allowLoose) {
         $checkValue = $input;
         if (is_string($checkValue)) {
             $checkValue = mb_strtolower(\Normalizer::normalize($checkValue));
         }
         if (in_array($checkValue, $this->trueValues ?: self::$defaultLooseTrue, true)) {
             $output = true;
         } elseif (in_array($checkValue, $this->falseValues ?: self::$defaultLooseFalse, true)) {
             $output = false;
         }
     }
     if ($output !== false && $output !== true) {
         $ctx->addReason($this, ['id' => 'bool.invalid']);
     }
     done:
     if ($output !== $input) {
         $ctx->setChange(Change::Internal);
     }
     return $output;
 }
开发者ID:shabbyrobe,项目名称:fulfil,代码行数:26,代码来源:Bool_.php


示例4: simplify_strings

function simplify_strings($string)
{
    //Normalisation de la chaine utf8 en mode caractère + accents
    $string = Normalizer::normalize($string, Normalizer::FORM_D);
    //Suppression des accents et minuscules
    return strtolower(preg_replace('~\\p{Mn}~u', '', $string));
}
开发者ID:RadioCampusFrance,项目名称:podcast-rccf,代码行数:7,代码来源:search.php


示例5: convertToValidCharacters

 /**
  * 入力を妥当な値に変換します。
  * @param string $input
  * @return string 変換できなかった場合は空文字列を返します。
  */
 protected function convertToValidCharacters(string $input) : string
 {
     $converted = preg_replace('/[\\p{C}\\p{Z}\\p{M}]+/u', '', \Normalizer::normalize(str_replace('~', '〜', $input), \Normalizer::FORM_KC));
     if ($this->isRegExp($converted)) {
         $converted = trim($converted, '/');
     }
     return $converted;
 }
开发者ID:esperecyan,项目名称:dictionary-php,代码行数:13,代码来源:AnswerValidator.php


示例6: asciify

function asciify($text)
{
    global $special_cases, $special_cases_keys;
    $text = Normalizer::normalize($text, Normalizer::FORM_C);
    $text = str_replace($special_cases_keys, $special_cases, $text);
    $text = Normalizer::normalize($text, Normalizer::FORM_D);
    return preg_replace('/[^\\x20-\\x7E]/', '', $text);
}
开发者ID:ox-it,项目名称:asciification,代码行数:8,代码来源:php.php


示例7: testNormalizer

 public function testNormalizer()
 {
     $english = Normalizer::factory();
     $greek = Normalizer::factory("Greek");
     $this->assertEquals(explode(" ", "ο μορφωμενοσ διαφερει απο τον αμορφωτο οσο ο ζωντανοσ απο τον νεκρο"), $greek->normalizeAll(explode(" ", "Ο μορφωμένος διαφέρει από τον αμόρφωτο όσο ο ζωντανός από τον νεκρό")));
     $this->assertEquals(explode(" ", "ο μορφωμένος διαφέρει από τον αμόρφωτο όσο ο ζωντανός από τον νεκρό"), $english->normalizeAll(explode(" ", "Ο μορφωμένος διαφέρει από τον αμόρφωτο όσο ο ζωντανός από τον νεκρό")));
     $this->assertEquals(explode(" ", "when a father gives to his son both laugh when a son gives to his father both cry"), $english->normalizeAll(explode(" ", "When a father gives to his son both laugh when a son gives to his father both cry")));
 }
开发者ID:LewisGet,项目名称:php-nlp-tools,代码行数:8,代码来源:NormalizerTest.php


示例8: testStringUnicodeDifferentNormalisationEqual

 function testStringUnicodeDifferentNormalisationEqual()
 {
     $a = \Normalizer::normalize("ő", \Normalizer::FORM_KC);
     $b = \Normalizer::normalize("ő", \Normalizer::FORM_D);
     $this->assertNotEquals($a, $b);
     $flat = $this->compare($a, $b);
     $this->assertTrue($flat->valid);
 }
开发者ID:shabbyrobe,项目名称:fulfil,代码行数:8,代码来源:EqualTest.php


示例9: __construct

 /**
  * Class constructor.
  *
  * @param mixed $string
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(string $string)
 {
     if (!mb_check_encoding($string, 'UTF-8')) {
         throw new \InvalidArgumentException('String is not valid UTF-8');
     }
     $string = \Normalizer::normalize($string);
     $this->string = $string;
     $this->length = mb_strlen($string, 'UTF-8');
 }
开发者ID:brick,项目名称:brick,代码行数:16,代码来源:UnicodeString.php


示例10: of

 /**
  * Public factory method.
  *
  * @param string $string
  *
  * @return UnicodeString
  *
  * @throws \InvalidArgumentException
  */
 public static function of(string $string)
 {
     if (!mb_check_encoding($string, 'UTF-8')) {
         throw new \InvalidArgumentException('String is not valid UTF-8');
     }
     $string = \Normalizer::normalize($string);
     $length = mb_strlen($string, 'UTF-8');
     return new UnicodeString($string, $length);
 }
开发者ID:brick,项目名称:type,代码行数:18,代码来源:UnicodeString.php


示例11: unaccent

 /**
  * @see https://github.com/alixaxel/phunction/blob/master/phunction/Text.php#L297
  */
 public static function unaccent($string)
 {
     if (extension_loaded('intl') === true) {
         $string = \Normalizer::normalize($string, \Normalizer::FORM_KD);
     }
     if (strpos($string = htmlentities($string, ENT_QUOTES, 'UTF-8'), '&') !== false) {
         $string = html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|caron|cedil|circ|grave|lig|orn|ring|slash|tilde|uml);~i', '$1', $string), ENT_QUOTES, 'UTF-8');
     }
     return $string;
 }
开发者ID:bobbiebenton,项目名称:herbie,代码行数:13,代码来源:StringHelper.php


示例12: checkAndNormaliseEncoding

 private function checkAndNormaliseEncoding(string $text) : string
 {
     if (!mb_check_encoding($text, self::ENCODING)) {
         throw new MessagePostFailureException('Message text encoding invalid');
     }
     $text = \Normalizer::normalize(rtrim($text), \Normalizer::FORM_C);
     if ($text === false) {
         throw new MessagePostFailureException('Failed to normalize message text');
     }
     return $text;
 }
开发者ID:Room-11,项目名称:Jeeves,代码行数:11,代码来源:ChatClient.php


示例13: utf8_new_case_fold_nfkc

function utf8_new_case_fold_nfkc($text, $option = 'full')
{
    static $fc_nfkc_closure = array("ͺ" => " ι", "ϒ" => "υ", "ϓ" => "ύ", "ϔ" => "ϋ", "ϲ" => "σ", "Ϲ" => "σ", "ᴬ" => "a", "ᴭ" => "æ", "ᴮ" => "b", "ᴰ" => "d", "ᴱ" => "e", "ᴲ" => "ǝ", "ᴳ" => "g", "ᴴ" => "h", "ᴵ" => "i", "ᴶ" => "j", "ᴷ" => "k", "ᴸ" => "l", "ᴹ" => "m", "ᴺ" => "n", "ᴼ" => "o", "ᴽ" => "ȣ", "ᴾ" => "p", "ᴿ" => "r", "ᵀ" => "t", "ᵁ" => "u", "ᵂ" => "w", "₨" => "rs", "ℂ" => "c", "℃" => "°c", "ℇ" => "ɛ", "℉" => "°f", "ℋ" => "h", "ℌ" => "h", "ℍ" => "h", "ℐ" => "i", "ℑ" => "i", "ℒ" => "l", "ℕ" => "n", "№" => "no", "ℙ" => "p", "ℚ" => "q", "ℛ" => "r", "ℜ" => "r", "ℝ" => "r", "℠" => "sm", "℡" => "tel", "™" => "tm", "ℤ" => "z", "ℨ" => "z", "ℬ" => "b", "ℭ" => "c", "ℰ" => "e", "ℱ" => "f", "ℳ" => "m", "℻" => "fax", "ℾ" => "γ", "ℿ" => "π", "ⅅ" => "d", "㉐" => "pte", "㋌" => "hg", "㋎" => "ev", "㋏" => "ltd", "㍱" => "hpa", "㍳" => "au", "㍵" => "ov", "㍺" => "iu", "㎀" => "pa", "㎁" => "na", "㎂" => "μa", "㎃" => "ma", "㎄" => "ka", "㎅" => "kb", "㎆" => "mb", "㎇" => "gb", "㎊" => "pf", "㎋" => "nf", "㎌" => "μf", "㎐" => "hz", "㎑" => "khz", "㎒" => "mhz", "㎓" => "ghz", "㎔" => "thz", "㎩" => "pa", "㎪" => "kpa", "㎫" => "mpa", "㎬" => "gpa", "㎴" => "pv", "㎵" => "nv", "㎶" => "μv", "㎷" => "mv", "㎸" => "kv", "㎹" => "mv", "㎺" => "pw", "㎻" => "nw", "㎼" => "μw", "㎽" => "mw", "㎾" => "kw", "㎿" => "mw", "㏀" => "kω", "㏁" => "mω", "㏃" => "bq", "㏆" => "c∕kg", "㏇" => "co.", "㏈" => "db", "㏉" => "gy", "㏋" => "hp", "㏍" => "kk", "㏎" => "km", "㏗" => "ph", "㏙" => "ppm", "㏚" => "pr", "㏜" => "sv", "㏝" => "wb", "㏞" => "v∕m", "㏟" => "a∕m", " 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Note类代码示例发布时间:2022-05-23
下一篇:
PHP NodeInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap