Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
commonnormalizer.php
1<?
3
4use \Bitrix\Main\Text\Encoding;
5
12{
16 public function normalize($string)
17 {
18 $result = $string;
19
20 // todo: \w on non-utf-8 sites
21 if(mb_strtolower(SITE_CHARSET) != 'utf-8')
22 {
23 $result = Encoding::convertEncoding($result, SITE_CHARSET, 'utf-8');
24 }
25
26 $result = preg_replace('/([^\w\s]|_)/iu', ' ', $result);
27
28 if(mb_strtolower(SITE_CHARSET) != 'utf-8')
29 {
30 $result = Encoding::convertEncoding($result, 'utf-8', SITE_CHARSET);
31 }
32
33 $result = preg_replace('/\s+/i'.BX_UTF_PCRE_MODIFIER, ' ', (string)$result);
34 $result = trim($result);
35 $result = ToUpper($result);
36 return $result;
37 }
38}