/phputf8/utils/specials.php
Utilities for processing "special" characters in UTF-8. "Special" largely means anything which would be regarded as a non-word character, like ASCII control characters and punctuation. This has a "Roman" bias - it would be unaware of modern Chinese "punctuation" characters for example.
Note: requires utils/unicode.php to be loaded
Checks a string for whether it contains only word characters. This
is logically equivalent to the \w PCRE meta character. Note that this is not a 100% guarantee that the string only contains alpha / numeric characters but just that common non-alphanumeric are not in the string, including ASCII device control characters.
- string $str: to check
Used internally. Builds a PCRE pattern from the $UTF8_SPECIAL_CHARS
array defined in this file This function adds the control chars 0x00 to 0x19 to the array of special chars (they are not included in $UTF8_SPECIAL_CHARS)
Removes special characters (nonalphanumeric) from a UTF-8 string
This can be useful as a helper for sanitizing a string for use as something like a file name or a unique identifier. Be warned though it does not handle all possible non-alphanumeric characters and is not intended is some kind of security / injection filter.
- string $string: The UTF8 string to strip of special chars
- string $repl: (optional) $repl Replace special with this string
Documentation generated on Mon, 05 Mar 2007 21:26:21 +0000 by phpDocumentor 1.3.1