PHP code example of imtigger / unicode-filter
1. Go to this page and download the library: Download imtigger/unicode-filter library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
imtigger / unicode-filter example snippets
echo UnicodeFilter::whitelist("Hello World! 😃", [
UnicodeFilter::BASIC_LATIN
]);
// Hello World!
echo UnicodeFilter::whitelist("Hello World! 😃", [
UnicodeFilter::BASIC_LATIN
], [], "_");
// Hello World! _
echo UnicodeFilter::blacklist("Hello World! 😃", [
UnicodeFilter::EMOTICONS
]);
// Hello World!
echo UnicodeFilter::whitelist("Hello\nWorld! 😃", [
UnicodeFilter::BASIC_LATIN
], [
[0x00, 0x20]
], "_");
// Hello_World! _
echo UnicodeFilter::whitelist("Hello 您好 こんにちは 안녕하세요 สวัสดีค่ะ", [
UnicodeFilter::BASIC_LATIN,
UnicodeFilter::CJK_UNIFIED_IDEOGRAPHS,
UnicodeFilter::CJK_COMPATIBILITY,
UnicodeFilter::HIRAGANA,
UnicodeFilter::KATAKANA,
UnicodeFilter::HANGUL_SYLLABLES
]);
// Hello 您好 こんにちは 안녕하세요
// (Thai is not
echo UnicodeFilter::whitelist("‷Hello×您好×こんにちは×안녕하세요×สวัสดีค่ะ‴ 😃", [
UnicodeFilter::BASIC_LATIN,
UnicodeFilter::CJK_UNIFIED_IDEOGRAPHS,
UnicodeFilter::CJK_COMPATIBILITY,
UnicodeFilter::HIRAGANA,
UnicodeFilter::KATAKANA,
UnicodeFilter::HANGUL_SYLLABLES,
UnicodeFilter::THAI,
UnicodeFilter::GENERAL_PUNCTUATION,
mb_ord('😃')
], [
[0x2000, 0x200F],
[0x205F, 0x206F]
], "_");
// ‷Hello_您好_こんにちは_안녕하세요_สวัสดีค่ะ‴ 😃
echo UnicodeFilter::dumpWhitelistInfo("Hello 您好", [
UnicodeFilter::BASIC_LATIN
]);
echo UnicodeFilter::dumpString("Hello×您好×こんにちは");
echo UnicodeFilter::dumpFilters([
UnicodeFilter::BASIC_LATIN,
UnicodeFilter::LATIN_1_SUPPLEMENT,
UnicodeFilter::LATIN_EXTENDED_A,
UnicodeFilter::LATIN_EXTENDED_B
]);
array(14) {
[0]=>
array(3) {
["character"]=>
string(1) "H"
["codepoint"]=>
int(72)
["block"]=>
string(11) "BASIC_LATIN"
}
...
}