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++ ) {
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
);
}