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