@@ -18,7 +18,7 @@ class Strings
1818{
1919 use Nette \StaticClass;
2020
21- const TRIM_CHARACTERS = " \t\n\r\0\x0B\xC2\xA0 " ;
21+ const TRIM_CHARACTERS = " \t\n\r\0\x0B\u{A0} " ;
2222
2323
2424 /**
@@ -163,15 +163,15 @@ public static function toAscii($s)
163163 $ s = preg_replace ('#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{2FF}\x{370}-\x{10FFFF}]#u ' , '' , $ s );
164164 $ s = strtr ($ s , '` \'"^~? ' , "\x01\x02\x03\x04\x05\x06" );
165165 $ s = str_replace (
166- ["\xE2\x80\x9E " , "\xE2\x80\x9C " , "\xE2\x80\x9D " , "\xE2\x80\x9A " , "\xE2\x80\x98 " , "\xE2\x80\x99 " , "\xC2\xB0 " ],
166+ ["\u{201E} " , "\u{201C} " , "\u{201D} " , "\u{201A} " , "\u{2018} " , "\u{2019} " , "\u{B0} " ],
167167 ["\x03" , "\x03" , "\x03" , "\x02" , "\x02" , "\x02" , "\x04" ], $ s
168168 );
169169 if ($ transliterator !== NULL ) {
170170 $ s = $ transliterator ->transliterate ($ s );
171171 }
172172 if (ICONV_IMPL === 'glibc ' ) {
173173 $ s = str_replace (
174- ["\xC2\xBB " , "\xC2\xAB " , "\xE2\x80\xA6 " , "\xE2\x84\xA2 " , "\xC2\xA9 " , "\xC2\xAE " ],
174+ ["\u{BB} " , "\u{AB} " , "\u{2026} " , "\u{2122} " , "\u{A9} " , "\u{AE} " ],
175175 ['>> ' , '<< ' , '... ' , 'TM ' , '(c) ' , '(R) ' ], $ s
176176 );
177177 $ s = iconv ('UTF-8 ' , 'WINDOWS-1250//TRANSLIT//IGNORE ' , $ s );
@@ -216,7 +216,7 @@ public static function webalize($s, $charlist = NULL, $lower = TRUE)
216216 * @param string UTF-8 encoding
217217 * @return string
218218 */
219- public static function truncate ($ s , $ maxLen , $ append = "\xE2\x80\xA6 " )
219+ public static function truncate (string $ s , int $ maxLen , string $ append = "\u{2026} " )
220220 {
221221 if (self ::length ($ s ) > $ maxLen ) {
222222 $ maxLen = $ maxLen - self ::length ($ append );
@@ -592,7 +592,7 @@ public static function pcre($func, $args)
592592 if (($ code = preg_last_error ()) // run-time error, but preg_last_error & return code are liars
593593 && ($ res === NULL || !in_array ($ func , ['preg_filter ' , 'preg_replace_callback ' , 'preg_replace ' ]))
594594 ) {
595- throw new RegexpException ((isset ( $ messages [$ code ]) ? $ messages [ $ code ] : 'Unknown error ' )
595+ throw new RegexpException (($ messages [$ code ] ?? 'Unknown error ' )
596596 . ' (pattern: ' . implode (' or ' , (array ) $ args [0 ]) . ') ' , $ code );
597597 }
598598 return $ res ;
0 commit comments