blob: 9a1e20c07b4d706e5e2bab5dbe75bd2bf5b0cb9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
namespace SMW\Utils;
/**
* @license GNU GPL v2+
* @since 3.0
*
* @author mwjames
*/
class CharArmor {
/**
* Remove invisible control characters and unused code points (using a
* negated character class to avoid removing spaces)
*
* @see http://www.regular-expressions.info/unicode.html#category
* @since 3.0
*
* @param string $text
*
* @return text
*/
public static function removeControlChars( $text ) {
return preg_replace('/[^\PC\s]/u', '', $text );
}
/**
* @since 3.0
*
* @param string $text
*
* @return text
*/
public static function removeSpecialChars( $text ) {
return str_replace(
[ '­', '‎', " ", " ", " " ],
[ '', '', ' ', ' ', ' ' ],
$text
);
}
}
|