note 127495 added to regexp.reference.unicode
| From: | phpnet at N_O_S_P_A_M dot osps dot net | Date: | Tue, 16 Aug 2022 11:22:54 +0000 |
| Subject: | note 127495 added to regexp.reference.unicode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219433@lists.php.net to get a copy of this message | ||
I found the predefined "supported" scripts helpful, except that there's no apparent
definition of what Unicode character ranges are covered by those definitions. So I wrote this to
determine them and print out the equivalent PCRE character class definitions. An example fragment of
output is (I can't include all output due to PHP.net Note-posting limits)
Canadian_Aboriginal=[\x{1400}-\x{167f}\x{18b0}-\x{18f5}]
The program:
<?php
$scriptNames = array(
'Arabic',
'Armenian',
'Avestan',
'Balinese',
'Bamum',
'Batak',
'Bengali',
'Bopomofo',
'Brahmi',
'Braille',
'Buginese',
'Buhid',
'Canadian_Aboriginal',
'Carian',
'Chakma',
'Cham',
'Cherokee',
'Common',
'Coptic',
'Cuneiform',
'Cypriot',
'Cyrillic',
'Deseret',
'Devanagari',
'Egyptian_Hieroglyphs',
'Ethiopic',
'Georgian',
'Glagolitic',
'Gothic',
'Greek',
'Gujarati',
'Gurmukhi',
'Han',
'Hangul',
'Hanunoo',
'Hebrew',
'Hiragana',
'Imperial_Aramaic',
'Inherited',
'Inscriptional_Pahlavi',
'Inscriptional_Parthian',
'Javanese',
'Kaithi',
'Kannada',
'Katakana',
'Kayah_Li',
'Kharoshthi',
'Khmer',
'Lao',
'Latin',
'Lepcha',
'Limbu',
'Linear_B',
'Lisu',
'Lycian',
'Lydian',
'Malayalam',
'Mandaic',
'Meetei_Mayek',
'Meroitic_Cursive',
'Meroitic_Hieroglyphs',
'Miao',
'Mongolian',
'Myanmar',
'New_Tai_Lue',
'Nko',
'Ogham',
'Old_Italic',
'Old_Persian',
'Old_South_Arabian',
'Old_Turkic',
'Ol_Chiki',
'Oriya',
'Osmanya',
'Phags_Pa',
'Phoenician',
'Rejang',
'Runic',
'Samaritan',
'Saurashtra',
'Sharada',
'Shavian',
'Sinhala',
'Sora_Sompeng',
'Sundanese',
'Syloti_Nagri',
'Syriac',
'Tagalog',
'Tagbanwa',
'Tai_Le',
'Tai_Tham',
'Tai_Viet',
'Takri',
'Tamil',
'Telugu',
'Thaana',
'Thai',
'Tibetan',
'Tifinagh',
'Ugaritic',
'Vai',
'Yi'
);
$scriptTypes = array();
foreach( $scriptNames as $n ) $scriptTypes[ $n ] = array();
for( $i=0; $i <= 0x10fff; $i++ ) {
//echo $i.PHP_EOL;
foreach( $scriptNames as $scriptName ) {
if ( preg_match( '/[\p{'. $scriptName .'}]/u', mb_chr( $i,
'UTF-8') ) ) {
if (empty( $scriptTypes[ $scriptName ])
|| ( ($i - $scriptTypes[ $scriptName ][ count( $scriptTypes[ $scriptName ] ) - 1
][1]) > 1)
) {
$scriptTypes[ $scriptName ][] = [$i, $i];
} else {
$scriptTypes[ $scriptName ][ count( $scriptTypes[ $scriptName ] ) - 1 ][1] = $i;
}
}
}
}
foreach( $scriptTypes as $scriptName => $unicodeRanges ) {
printf(
'%s=[',
$scriptName
);
foreach( $unicodeRanges as $r ) {
printf(
'\x{%04x}',
$r[0]
);
if ($r[1] > $r[0] )
printf(
'-\x{%04x}',
$r[1]
);
}
printf(
']'.PHP_EOL
);
}
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.173 (proxied: 62.3.121.6)
----
Manual Page -- https://php.net/manual/en/regexp.reference.unicode.php
Edit -- https://main.php.net/note/edit/127495
Del: integrated -- https://main.php.net/note/delete/127495/integrated
Del: useless -- https://main.php.net/note/delete/127495/useless
Del: bad code -- https://main.php.net/note/delete/127495/bad+code
Del: spam -- https://main.php.net/note/delete/127495/spam
Del: non-english -- https://main.php.net/note/delete/127495/non-english
Del: in docs -- https://main.php.net/note/delete/127495/in+docs
Del: other reasons-- https://main.php.net/note/delete/127495
Reject -- https://main.php.net/note/reject/127495
Search -- https://main.php.net/manage/user-notes.php