Home | History | Annotate | Download | only in lang
      1 /* GENERATED SOURCE. DO NOT MODIFY. */
      2 //  2016 and later: Unicode, Inc. and others.
      3 // License & terms of use: http://www.unicode.org/copyright.html#License
      4 /**
      5  *******************************************************************************
      6  * Copyright (C) 2001-2016 International Business Machines Corporation and
      7  * others. All Rights Reserved.
      8  *******************************************************************************
      9  */
     10 
     11 package android.icu.lang;
     12 
     13 import java.util.BitSet;
     14 import java.util.Locale;
     15 
     16 import android.icu.impl.UCharacterProperty;
     17 import android.icu.util.ULocale;
     18 
     19 /**
     20  * Constants for ISO 15924 script codes, and related functions.
     21  *
     22  * <p>The current set of script code constants supports at least all scripts
     23  * that are encoded in the version of Unicode which ICU currently supports.
     24  * The names of the constants are usually derived from the
     25  * Unicode script property value aliases.
     26  * See UAX #24 Unicode Script Property (http://www.unicode.org/reports/tr24/)
     27  * and http://www.unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt .
     28  *
     29  * <p>In addition, constants for many ISO 15924 script codes
     30  * are included, for use with language tags, CLDR data, and similar.
     31  * Some of those codes are not used in the Unicode Character Database (UCD).
     32  * For example, there are no characters that have a UCD script property value of
     33  * Hans or Hant. All Han ideographs have the Hani script property value in Unicode.
     34  *
     35  * <p>Private-use codes Qaaa..Qabx are not included, except as used in the UCD or in CLDR.
     36  *
     37  * <p>Starting with ICU 55, script codes are only added when their scripts
     38  * have been or will certainly be encoded in Unicode,
     39  * and have been assigned Unicode script property value aliases,
     40  * to ensure that their script names are stable and match the names of the constants.
     41  * Script codes like Latf and Aran that are not subject to separate encoding
     42  * may be added at any time.
     43  */
     44 public final class UScript {
     45     /**
     46      * Invalid code
     47      */
     48     public static final int INVALID_CODE = -1;
     49     /**
     50      * Common
     51      */
     52     public static final int COMMON       =  0;  /* Zyyy */
     53     /**
     54      * Inherited
     55      */
     56     public static final int INHERITED    =  1;  /* Zinh */ /* "Code for inherited script", for non-spacing combining marks; also Qaai */
     57     /**
     58      * Arabic
     59      */
     60     public static final int ARABIC       =  2;  /* Arab */
     61     /**
     62      * Armenian
     63      */
     64     public static final int ARMENIAN     =  3;  /* Armn */
     65     /**
     66      * Bengali
     67      */
     68     public static final int BENGALI      =  4;  /* Beng */
     69     /**
     70      * Bopomofo
     71      */
     72     public static final int BOPOMOFO     =  5;  /* Bopo */
     73     /**
     74      * Cherokee
     75      */
     76     public static final int CHEROKEE     =  6;  /* Cher */
     77     /**
     78      * Coptic
     79      */
     80     public static final int COPTIC       =  7;  /* Qaac */
     81     /**
     82      * Cyrillic
     83      */
     84     public static final int CYRILLIC     =  8;  /* Cyrl (Cyrs) */
     85     /**
     86      * Deseret
     87      */
     88     public static final int DESERET      =  9;  /* Dsrt */
     89     /**
     90      * Devanagari
     91      */
     92     public static final int DEVANAGARI   = 10;  /* Deva */
     93     /**
     94      * Ethiopic
     95      */
     96     public static final int ETHIOPIC     = 11;  /* Ethi */
     97     /**
     98      * Georgian
     99      */
    100     public static final int GEORGIAN     = 12;  /* Geor (Geon; Geoa) */
    101     /**
    102      * Gothic
    103      */
    104     public static final int GOTHIC       = 13;  /* Goth */
    105     /**
    106      * Greek
    107      */
    108     public static final int GREEK        = 14;  /* Grek */
    109     /**
    110      * Gujarati
    111      */
    112     public static final int GUJARATI     = 15;  /* Gujr */
    113     /**
    114      * Gurmukhi
    115      */
    116     public static final int GURMUKHI     = 16;  /* Guru */
    117     /**
    118      * Han
    119      */
    120     public static final int HAN          = 17;  /* Hani */
    121     /**
    122      * Hangul
    123      */
    124     public static final int HANGUL       = 18;  /* Hang */
    125     /**
    126      * Hebrew
    127      */
    128     public static final int HEBREW       = 19;  /* Hebr */
    129     /**
    130      * Hiragana
    131      */
    132     public static final int HIRAGANA     = 20;  /* Hira */
    133     /**
    134      * Kannada
    135      */
    136     public static final int KANNADA      = 21;  /* Knda */
    137     /**
    138      * Katakana
    139      */
    140     public static final int KATAKANA     = 22;  /* Kana */
    141     /**
    142      * Khmer
    143      */
    144     public static final int KHMER        = 23;  /* Khmr */
    145     /**
    146      * Lao
    147      */
    148     public static final int LAO          = 24;  /* Laoo */
    149     /**
    150      * Latin
    151      */
    152     public static final int LATIN        = 25;  /* Latn (Latf; Latg) */
    153     /**
    154      * Malayalam
    155      */
    156     public static final int MALAYALAM    = 26;  /* Mlym */
    157     /**
    158      * Mangolian
    159      */
    160     public static final int MONGOLIAN    = 27;  /* Mong */
    161     /**
    162      * Myammar
    163      */
    164     public static final int MYANMAR      = 28;  /* Mymr */
    165     /**
    166      * Ogham
    167      */
    168     public static final int OGHAM        = 29;  /* Ogam */
    169     /**
    170      * Old Itallic
    171      */
    172     public static final int OLD_ITALIC   = 30;  /* Ital */
    173     /**
    174      * Oriya
    175      */
    176     public static final int ORIYA        = 31;  /* Orya */
    177     /**
    178      * Runic
    179      */
    180     public static final int RUNIC        = 32;  /* Runr */
    181     /**
    182      * Sinhala
    183      */
    184     public static final int SINHALA      = 33;  /* Sinh */
    185     /**
    186      * Syriac
    187      */
    188     public static final int SYRIAC       = 34;  /* Syrc (Syrj; Syrn; Syre) */
    189     /**
    190      * Tamil
    191      */
    192     public static final int TAMIL        = 35;  /* Taml */
    193     /**
    194      * Telugu
    195      */
    196     public static final int TELUGU       = 36;  /* Telu */
    197     /**
    198      * Thana
    199      */
    200     public static final int THAANA       = 37;  /* Thaa */
    201     /**
    202      * Thai
    203      */
    204     public static final int THAI         = 38;  /* Thai */
    205     /**
    206      * Tibetan
    207      */
    208     public static final int TIBETAN      = 39;  /* Tibt */
    209     /**
    210      * Unified Canadian Aboriginal Symbols
    211      */
    212     public static final int CANADIAN_ABORIGINAL = 40;  /* Cans */
    213     /**
    214      * Unified Canadian Aboriginal Symbols (alias)
    215      */
    216     public static final int UCAS         = CANADIAN_ABORIGINAL;  /* Cans */
    217     /**
    218      * Yi syllables
    219      */
    220     public static final int YI           = 41;  /* Yiii */
    221     /**
    222      * Tagalog
    223      */
    224     public static final int TAGALOG      = 42;  /* Tglg */
    225     /**
    226      * Hanunooo
    227      */
    228     public static final int HANUNOO      = 43;  /* Hano */
    229     /**
    230      * Buhid
    231      */
    232     public static final int BUHID        = 44;  /* Buhd */
    233     /**
    234      * Tagbanwa
    235      */
    236     public static final int TAGBANWA     = 45;  /* Tagb */
    237     /**
    238      * Braille
    239      * Script in Unicode 4
    240      *
    241      */
    242     public static final int BRAILLE      = 46;  /* Brai */
    243     /**
    244      * Cypriot
    245      * Script in Unicode 4
    246      *
    247      */
    248     public static final int CYPRIOT              = 47;  /* Cprt */
    249     /**
    250      * Limbu
    251      * Script in Unicode 4
    252      *
    253      */
    254     public static final int LIMBU                = 48;  /* Limb */
    255     /**
    256      * Linear B
    257      * Script in Unicode 4
    258      *
    259      */
    260     public static final int LINEAR_B     = 49;  /* Linb */
    261     /**
    262      * Osmanya
    263      * Script in Unicode 4
    264      *
    265      */
    266     public static final int OSMANYA              = 50;  /* Osma */
    267     /**
    268      * Shavian
    269      * Script in Unicode 4
    270      *
    271      */
    272     public static final int SHAVIAN              = 51;  /* Shaw */
    273     /**
    274      * Tai Le
    275      * Script in Unicode 4
    276      *
    277      */
    278     public static final int TAI_LE               = 52;  /* Tale */
    279     /**
    280      * Ugaritic
    281      * Script in Unicode 4
    282      *
    283      */
    284     public static final int UGARITIC     = 53;  /* Ugar */
    285     /**
    286      * Script in Unicode 4.0.1
    287      */
    288     public static final int KATAKANA_OR_HIRAGANA = 54;  /*Hrkt */
    289 
    290     /**
    291      * Script in Unicode 4.1
    292      */
    293     public static final int BUGINESE = 55;           /* Bugi */
    294     /**
    295      * Script in Unicode 4.1
    296      */
    297     public static final int GLAGOLITIC = 56;         /* Glag */
    298     /**
    299      * Script in Unicode 4.1
    300      */
    301     public static final int KHAROSHTHI = 57;         /* Khar */
    302     /**
    303      * Script in Unicode 4.1
    304      */
    305     public static final int SYLOTI_NAGRI = 58;       /* Sylo */
    306     /**
    307      * Script in Unicode 4.1
    308      */
    309     public static final int NEW_TAI_LUE = 59;        /* Talu */
    310     /**
    311      * Script in Unicode 4.1
    312      */
    313     public static final int TIFINAGH = 60;           /* Tfng */
    314     /**
    315      * Script in Unicode 4.1
    316      */
    317     public static final int OLD_PERSIAN = 61;        /* Xpeo */
    318 
    319 
    320     /**
    321      * ISO 15924 script code
    322      */
    323     public static final int BALINESE                      = 62; /* Bali */
    324     /**
    325      * ISO 15924 script code
    326      */
    327     public static final int BATAK                         = 63; /* Batk */
    328     /**
    329      * ISO 15924 script code
    330      */
    331     public static final int BLISSYMBOLS                   = 64; /* Blis */
    332     /**
    333      * ISO 15924 script code
    334      */
    335     public static final int BRAHMI                        = 65; /* Brah */
    336     /**
    337      * ISO 15924 script code
    338      */
    339     public static final int CHAM                          = 66; /* Cham */
    340     /**
    341      * ISO 15924 script code
    342      */
    343     public static final int CIRTH                         = 67; /* Cirt */
    344     /**
    345      * ISO 15924 script code
    346      */
    347     public static final int OLD_CHURCH_SLAVONIC_CYRILLIC  = 68; /* Cyrs */
    348     /**
    349      * ISO 15924 script code
    350      */
    351     public static final int DEMOTIC_EGYPTIAN              = 69; /* Egyd */
    352     /**
    353      * ISO 15924 script code
    354      */
    355     public static final int HIERATIC_EGYPTIAN             = 70; /* Egyh */
    356     /**
    357      * ISO 15924 script code
    358      */
    359     public static final int EGYPTIAN_HIEROGLYPHS          = 71; /* Egyp */
    360     /**
    361      * ISO 15924 script code
    362      */
    363     public static final int KHUTSURI                      = 72; /* Geok */
    364     /**
    365      * ISO 15924 script code
    366      */
    367     public static final int SIMPLIFIED_HAN                = 73; /* Hans */
    368     /**
    369      * ISO 15924 script code
    370      */
    371     public static final int TRADITIONAL_HAN               = 74; /* Hant */
    372     /**
    373      * ISO 15924 script code
    374      */
    375     public static final int PAHAWH_HMONG                  = 75; /* Hmng */
    376     /**
    377      * ISO 15924 script code
    378      */
    379     public static final int OLD_HUNGARIAN                 = 76; /* Hung */
    380     /**
    381      * ISO 15924 script code
    382      */
    383     public static final int HARAPPAN_INDUS                = 77; /* Inds */
    384     /**
    385      * ISO 15924 script code
    386      */
    387     public static final int JAVANESE                      = 78; /* Java */
    388     /**
    389      * ISO 15924 script code
    390      */
    391     public static final int KAYAH_LI                      = 79; /* Kali */
    392     /**
    393      * ISO 15924 script code
    394      */
    395     public static final int LATIN_FRAKTUR                 = 80; /* Latf */
    396     /**
    397      * ISO 15924 script code
    398      */
    399     public static final int LATIN_GAELIC                  = 81; /* Latg */
    400     /**
    401      * ISO 15924 script code
    402      */
    403     public static final int LEPCHA                        = 82; /* Lepc */
    404     /**
    405      * ISO 15924 script code
    406      */
    407     public static final int LINEAR_A                      = 83; /* Lina */
    408     /**
    409      * ISO 15924 script code
    410      */
    411     public static final int MANDAIC                       = 84; /* Mand */
    412     /**
    413      * ISO 15924 script code
    414      */
    415     public static final int MANDAEAN                      = MANDAIC;
    416     /**
    417      * ISO 15924 script code
    418      */
    419     public static final int MAYAN_HIEROGLYPHS             = 85; /* Maya */
    420     /**
    421      * ISO 15924 script code
    422      */
    423     public static final int MEROITIC_HIEROGLYPHS          = 86; /* Mero */
    424     /**
    425      * ISO 15924 script code
    426      */
    427     public static final int MEROITIC                      = MEROITIC_HIEROGLYPHS;
    428     /**
    429      * ISO 15924 script code
    430      */
    431     public static final int NKO                           = 87; /* Nkoo */
    432     /**
    433      * ISO 15924 script code
    434      */
    435     public static final int ORKHON                        = 88; /* Orkh */
    436     /**
    437      * ISO 15924 script code
    438      */
    439     public static final int OLD_PERMIC                    = 89; /* Perm */
    440     /**
    441      * ISO 15924 script code
    442      */
    443     public static final int PHAGS_PA                      = 90; /* Phag */
    444     /**
    445      * ISO 15924 script code
    446      */
    447     public static final int PHOENICIAN                    = 91; /* Phnx */
    448     /**
    449      * ISO 15924 script code
    450      */
    451     public static final int MIAO                          = 92; /* Plrd */
    452     /**
    453      * ISO 15924 script code
    454      */
    455     public static final int PHONETIC_POLLARD              = MIAO;
    456     /**
    457      * ISO 15924 script code
    458      */
    459     public static final int RONGORONGO                    = 93; /* Roro */
    460     /**
    461      * ISO 15924 script code
    462      */
    463     public static final int SARATI                        = 94; /* Sara */
    464     /**
    465      * ISO 15924 script code
    466      */
    467     public static final int ESTRANGELO_SYRIAC             = 95; /* Syre */
    468     /**
    469      * ISO 15924 script code
    470      */
    471     public static final int WESTERN_SYRIAC                = 96; /* Syrj */
    472     /**
    473      * ISO 15924 script code
    474      */
    475     public static final int EASTERN_SYRIAC                = 97; /* Syrn */
    476     /**
    477      * ISO 15924 script code
    478      */
    479     public static final int TENGWAR                       = 98; /* Teng */
    480     /**
    481      * ISO 15924 script code
    482      */
    483     public static final int VAI                           = 99; /* Vaii */
    484     /**
    485      * ISO 15924 script code
    486      */
    487     public static final int VISIBLE_SPEECH                = 100;/* Visp */
    488     /**
    489      * ISO 15924 script code
    490      */
    491     public static final int CUNEIFORM                     = 101;/* Xsux */
    492     /**
    493      * ISO 15924 script code
    494      */
    495     public static final int UNWRITTEN_LANGUAGES           = 102;/* Zxxx */
    496     /**
    497      * ISO 15924 script code
    498      */
    499     public static final int UNKNOWN                       = 103;/* Zzzz */ /* Unknown="Code for uncoded script", for unassigned code points */
    500 
    501     /**
    502      * ISO 15924 script code
    503      */
    504     public static final int CARIAN                        = 104;/* Cari */
    505     /**
    506      * ISO 15924 script code
    507      */
    508     public static final int JAPANESE                      = 105;/* Jpan */
    509     /**
    510      * ISO 15924 script code
    511      */
    512     public static final int LANNA                         = 106;/* Lana */
    513     /**
    514      * ISO 15924 script code
    515      */
    516     public static final int LYCIAN                        = 107;/* Lyci */
    517     /**
    518      * ISO 15924 script code
    519      */
    520     public static final int LYDIAN                        = 108;/* Lydi */
    521     /**
    522      * ISO 15924 script code
    523      */
    524     public static final int OL_CHIKI                      = 109;/* Olck */
    525     /**
    526      * ISO 15924 script code
    527      */
    528     public static final int REJANG                        = 110;/* Rjng */
    529     /**
    530      * ISO 15924 script code
    531      */
    532     public static final int SAURASHTRA                    = 111;/* Saur */
    533     /**
    534      * ISO 15924 script code for Sutton SignWriting
    535      */
    536     public static final int SIGN_WRITING                  = 112;/* Sgnw */
    537     /**
    538      * ISO 15924 script code
    539      */
    540     public static final int SUNDANESE                     = 113;/* Sund */
    541     /**
    542      * ISO 15924 script code
    543      */
    544     public static final int MOON                          = 114;/* Moon */
    545     /**
    546      * ISO 15924 script code
    547      */
    548     public static final int MEITEI_MAYEK                  = 115;/* Mtei */
    549 
    550     /**
    551      * ISO 15924 script code
    552      */
    553     public static final int IMPERIAL_ARAMAIC              = 116;/* Armi */
    554 
    555     /**
    556      * ISO 15924 script code
    557      */
    558     public static final int AVESTAN                       = 117;/* Avst */
    559 
    560     /**
    561      * ISO 15924 script code
    562      */
    563     public static final int CHAKMA                        = 118;/* Cakm */
    564 
    565     /**
    566      * ISO 15924 script code
    567      */
    568     public static final int KOREAN                        = 119;/* Kore */
    569 
    570     /**
    571      * ISO 15924 script code
    572      */
    573     public static final int KAITHI                        = 120;/* Kthi */
    574 
    575     /**
    576      * ISO 15924 script code
    577      */
    578     public static final int MANICHAEAN                    = 121;/* Mani */
    579 
    580     /**
    581      * ISO 15924 script code
    582      */
    583     public static final int INSCRIPTIONAL_PAHLAVI         = 122;/* Phli */
    584 
    585     /**
    586      * ISO 15924 script code
    587      */
    588     public static final int PSALTER_PAHLAVI               = 123;/* Phlp */
    589 
    590     /**
    591      * ISO 15924 script code
    592      */
    593     public static final int BOOK_PAHLAVI                  = 124;/* Phlv */
    594 
    595     /**
    596      * ISO 15924 script code
    597      */
    598     public static final int INSCRIPTIONAL_PARTHIAN        = 125;/* Prti */
    599 
    600     /**
    601      * ISO 15924 script code
    602      */
    603     public static final int SAMARITAN                     = 126;/* Samr */
    604 
    605     /**
    606      * ISO 15924 script code
    607      */
    608     public static final int TAI_VIET                      = 127;/* Tavt */
    609 
    610     /**
    611      * ISO 15924 script code
    612      */
    613     public static final int MATHEMATICAL_NOTATION         = 128;/* Zmth */
    614 
    615     /**
    616      * ISO 15924 script code
    617      */
    618     public static final int SYMBOLS                       = 129;/* Zsym */
    619 
    620     /**
    621      * ISO 15924 script code
    622      */
    623     public static final int BAMUM                         = 130;/* Bamu */
    624     /**
    625      * ISO 15924 script code
    626      */
    627     public static final int LISU                          = 131;/* Lisu */
    628     /**
    629      * ISO 15924 script code
    630      */
    631     public static final int NAKHI_GEBA                    = 132;/* Nkgb */
    632     /**
    633      * ISO 15924 script code
    634      */
    635     public static final int OLD_SOUTH_ARABIAN             = 133;/* Sarb */
    636 
    637     /**
    638      * ISO 15924 script code
    639      */
    640     public static final int BASSA_VAH                     = 134;/* Bass */
    641     /**
    642      * ISO 15924 script code
    643      */
    644     public static final int DUPLOYAN                      = 135;/* Dupl */
    645     /**
    646      * Typo, use DUPLOYAN
    647      * @deprecated ICU 54
    648      * @hide original deprecated declaration
    649      */
    650     @Deprecated
    651     public static final int DUPLOYAN_SHORTAND             = DUPLOYAN;
    652     /**
    653      * ISO 15924 script code
    654      */
    655     public static final int ELBASAN                       = 136;/* Elba */
    656     /**
    657      * ISO 15924 script code
    658      */
    659     public static final int GRANTHA                       = 137;/* Gran */
    660     /**
    661      * ISO 15924 script code
    662      */
    663     public static final int KPELLE                        = 138;/* Kpel */
    664     /**
    665      * ISO 15924 script code
    666      */
    667     public static final int LOMA                          = 139;/* Loma */
    668     /**
    669      * Mende Kikakui
    670      * ISO 15924 script code
    671      */
    672     public static final int MENDE                         = 140;/* Mend */
    673     /**
    674      * ISO 15924 script code
    675      */
    676     public static final int MEROITIC_CURSIVE              = 141;/* Merc */
    677     /**
    678      * ISO 15924 script code
    679      */
    680     public static final int OLD_NORTH_ARABIAN             = 142;/* Narb */
    681     /**
    682      * ISO 15924 script code
    683      */
    684     public static final int NABATAEAN                     = 143;/* Nbat */
    685     /**
    686      * ISO 15924 script code
    687      */
    688     public static final int PALMYRENE                     = 144;/* Palm */
    689     /**
    690      * ISO 15924 script code
    691      */
    692     public static final int KHUDAWADI                     = 145;/* Sind */
    693     /**
    694      * ISO 15924 script code
    695      */
    696     public static final int SINDHI = KHUDAWADI;
    697     /**
    698      * ISO 15924 script code
    699      */
    700     public static final int WARANG_CITI                   = 146;/* Wara */
    701 
    702     /**
    703      * ISO 15924 script code
    704      */
    705     public static final int AFAKA = 147;/* Afak */
    706     /**
    707      * ISO 15924 script code
    708      */
    709     public static final int JURCHEN = 148;/* Jurc */
    710     /**
    711      * ISO 15924 script code
    712      */
    713     public static final int MRO = 149;/* Mroo */
    714     /**
    715      * ISO 15924 script code
    716      */
    717     public static final int NUSHU = 150;/* Nshu */
    718     /**
    719      * ISO 15924 script code
    720      */
    721     public static final int SHARADA = 151;/* Shrd */
    722     /**
    723      * ISO 15924 script code
    724      */
    725     public static final int SORA_SOMPENG = 152;/* Sora */
    726     /**
    727      * ISO 15924 script code
    728      */
    729     public static final int TAKRI = 153;/* Takr */
    730     /**
    731      * ISO 15924 script code
    732      */
    733     public static final int TANGUT = 154;/* Tang */
    734     /**
    735      * ISO 15924 script code
    736      */
    737     public static final int WOLEAI = 155;/* Wole */
    738 
    739     /**
    740      * ISO 15924 script code
    741      */
    742     public static final int ANATOLIAN_HIEROGLYPHS = 156;/* Hluw */
    743     /**
    744      * ISO 15924 script code
    745      */
    746     public static final int KHOJKI = 157;/* Khoj */
    747     /**
    748      * ISO 15924 script code
    749      */
    750     public static final int TIRHUTA = 158;/* Tirh */
    751     /**
    752      * ISO 15924 script code
    753      */
    754     public static final int CAUCASIAN_ALBANIAN = 159; /* Aghb */
    755     /**
    756      * ISO 15924 script code
    757      */
    758     public static final int MAHAJANI = 160; /* Mahj */
    759 
    760     /**
    761      * ISO 15924 script code
    762      */
    763     public static final int AHOM = 161; /* Ahom */
    764     /**
    765      * ISO 15924 script code
    766      */
    767     public static final int HATRAN = 162; /* Hatr */
    768     /**
    769      * ISO 15924 script code
    770      */
    771     public static final int MODI = 163; /* Modi */
    772     /**
    773      * ISO 15924 script code
    774      */
    775     public static final int MULTANI = 164; /* Mult */
    776     /**
    777      * ISO 15924 script code
    778      */
    779     public static final int PAU_CIN_HAU = 165; /* Pauc */
    780     /**
    781      * ISO 15924 script code
    782      */
    783     public static final int SIDDHAM = 166; /* Sidd */
    784 
    785     /**
    786      * ISO 15924 script code
    787      */
    788     public static final int ADLAM = 167; /* Adlm */
    789     /**
    790      * ISO 15924 script code
    791      */
    792     public static final int BHAIKSUKI = 168; /* Bhks */
    793     /**
    794      * ISO 15924 script code
    795      */
    796     public static final int MARCHEN = 169; /* Marc */
    797     /**
    798      * ISO 15924 script code
    799      */
    800     public static final int NEWA = 170; /* Newa */
    801     /**
    802      * ISO 15924 script code
    803      */
    804     public static final int OSAGE = 171; /* Osge */
    805 
    806     /**
    807      * ISO 15924 script code
    808      */
    809     public static final int HAN_WITH_BOPOMOFO = 172; /* Hanb */
    810     /**
    811      * ISO 15924 script code
    812      */
    813     public static final int JAMO = 173; /* Jamo */
    814     /**
    815      * ISO 15924 script code
    816      */
    817     public static final int SYMBOLS_EMOJI = 174; /* Zsye */
    818 
    819     /**
    820      * ISO 15924 script code
    821      */
    822     public static final int MASARAM_GONDI = 175; /* Gonm */
    823     /**
    824      * ISO 15924 script code
    825      */
    826     public static final int SOYOMBO = 176; /* Soyo */
    827     /**
    828      * ISO 15924 script code
    829      */
    830     public static final int ZANABAZAR_SQUARE = 177; /* Zanb */
    831 
    832     /**
    833      * One more than the highest normal UScript code.
    834      * The highest value is available via UCharacter.getIntPropertyMaxValue(UProperty.SCRIPT).
    835      *
    836      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
    837      * @hide unsupported on Android
    838      */
    839     @Deprecated
    840     public static final int CODE_LIMIT   = 178;
    841 
    842     private static int[] getCodesFromLocale(ULocale locale) {
    843         // Multi-script languages, equivalent to the LocaleScript data
    844         // that we used to load from locale resource bundles.
    845         String lang = locale.getLanguage();
    846         if(lang.equals("ja")) {
    847             return new int[] { UScript.KATAKANA, UScript.HIRAGANA, UScript.HAN };
    848         }
    849         if(lang.equals("ko")) {
    850             return new int[] { UScript.HANGUL, UScript.HAN };
    851         }
    852         String script = locale.getScript();
    853         if(lang.equals("zh") && script.equals("Hant")) {
    854             return new int[] { UScript.HAN, UScript.BOPOMOFO };
    855         }
    856         // Explicit script code.
    857         if(script.length() != 0) {
    858             int scriptCode = UScript.getCodeFromName(script);
    859             if(scriptCode != UScript.INVALID_CODE) {
    860                 if(scriptCode == UScript.SIMPLIFIED_HAN || scriptCode == UScript.TRADITIONAL_HAN) {
    861                     scriptCode = UScript.HAN;
    862                 }
    863                 return new int[] { scriptCode };
    864             }
    865         }
    866         return null;
    867     }
    868 
    869     /**
    870      * Helper function to find the code from locale.
    871      * @param locale The locale.
    872      */
    873     private static int[] findCodeFromLocale(ULocale locale) {
    874         int[] result = getCodesFromLocale(locale);
    875         if(result != null) {
    876             return result;
    877         }
    878         ULocale likely = ULocale.addLikelySubtags(locale);
    879         return getCodesFromLocale(likely);
    880     }
    881 
    882     /**
    883      * Gets a script codes associated with the given locale or ISO 15924 abbreviation or name.
    884      * Returns MALAYAM given "Malayam" OR "Mlym".
    885      * Returns LATIN given "en" OR "en_US"
    886      * @param locale Locale
    887      * @return The script codes array. null if the the code cannot be found.
    888      */
    889     public static final int[] getCode(Locale locale){
    890         return findCodeFromLocale(ULocale.forLocale(locale));
    891     }
    892     /**
    893      * Gets a script codes associated with the given locale or ISO 15924 abbreviation or name.
    894      * Returns MALAYAM given "Malayam" OR "Mlym".
    895      * Returns LATIN given "en" OR "en_US"
    896      * @param locale ULocale
    897      * @return The script codes array. null if the the code cannot be found.
    898      */
    899     public static final int[] getCode(ULocale locale){
    900         return findCodeFromLocale(locale);
    901     }
    902     /**
    903      * Gets the script codes associated with the given locale or ISO 15924 abbreviation or name.
    904      * Returns MALAYAM given "Malayam" OR "Mlym".
    905      * Returns LATIN given "en" OR "en_US"
    906      *
    907      * <p>Note: To search by short or long script alias only, use
    908      * {@link #getCodeFromName(String)} instead.
    909      * That does a fast lookup with no access of the locale data.
    910      *
    911      * @param nameOrAbbrOrLocale name of the script or ISO 15924 code or locale
    912      * @return The script codes array. null if the the code cannot be found.
    913      */
    914     public static final int[] getCode(String nameOrAbbrOrLocale) {
    915         boolean triedCode = false;
    916         if (nameOrAbbrOrLocale.indexOf('_') < 0 && nameOrAbbrOrLocale.indexOf('-') < 0) {
    917             int propNum = UCharacter.getPropertyValueEnumNoThrow(UProperty.SCRIPT, nameOrAbbrOrLocale);
    918             if (propNum != UProperty.UNDEFINED) {
    919                 return new int[] {propNum};
    920             }
    921             triedCode = true;
    922         }
    923         int[] scripts = findCodeFromLocale(new ULocale(nameOrAbbrOrLocale));
    924         if (scripts != null) {
    925             return scripts;
    926         }
    927         if (!triedCode) {
    928             int propNum = UCharacter.getPropertyValueEnumNoThrow(UProperty.SCRIPT, nameOrAbbrOrLocale);
    929             if (propNum != UProperty.UNDEFINED) {
    930                 return new int[] {propNum};
    931             }
    932         }
    933         return null;
    934     }
    935 
    936     /**
    937      * Returns the script code associated with the given Unicode script property alias
    938      * (name or abbreviation).
    939      * Short aliases are ISO 15924 script codes.
    940      * Returns MALAYAM given "Malayam" OR "Mlym".
    941      *
    942      * @param nameOrAbbr name of the script or ISO 15924 code
    943      * @return The script code value, or INVALID_CODE if the code cannot be found.
    944      */
    945     public static final int getCodeFromName(String nameOrAbbr) {
    946         int propNum = UCharacter.getPropertyValueEnumNoThrow(UProperty.SCRIPT, nameOrAbbr);
    947         return propNum == UProperty.UNDEFINED ? INVALID_CODE : propNum;
    948     }
    949 
    950     /**
    951      * Gets the script code associated with the given codepoint.
    952      * Returns UScript.MALAYAM given 0x0D02
    953      * @param codepoint UChar32 codepoint
    954      * @return The script code
    955      */
    956     public static final int getScript(int codepoint){
    957         if (codepoint >= UCharacter.MIN_VALUE & codepoint <= UCharacter.MAX_VALUE) {
    958             int scriptX=UCharacterProperty.INSTANCE.getAdditional(codepoint, 0)&UCharacterProperty.SCRIPT_X_MASK;
    959             if(scriptX<UCharacterProperty.SCRIPT_X_WITH_COMMON) {
    960                 return scriptX;
    961             } else if(scriptX<UCharacterProperty.SCRIPT_X_WITH_INHERITED) {
    962                 return UScript.COMMON;
    963             } else if(scriptX<UCharacterProperty.SCRIPT_X_WITH_OTHER) {
    964                 return UScript.INHERITED;
    965             } else {
    966                 return UCharacterProperty.INSTANCE.m_scriptExtensions_[scriptX&UCharacterProperty.SCRIPT_MASK_];
    967             }
    968         }else{
    969             throw new IllegalArgumentException(Integer.toString(codepoint));
    970         }
    971     }
    972 
    973     /**
    974      * Do the Script_Extensions of code point c contain script sc?
    975      * If c does not have explicit Script_Extensions, then this tests whether
    976      * c has the Script property value sc.
    977      *
    978      * <p>Some characters are commonly used in multiple scripts.
    979      * For more information, see UAX #24: http://www.unicode.org/reports/tr24/.
    980      *
    981      * @param c code point
    982      * @param sc script code
    983      * @return true if sc is in Script_Extensions(c)
    984      */
    985     public static final boolean hasScript(int c, int sc) {
    986         int scriptX=UCharacterProperty.INSTANCE.getAdditional(c, 0)&UCharacterProperty.SCRIPT_X_MASK;
    987         if(scriptX<UCharacterProperty.SCRIPT_X_WITH_COMMON) {
    988             return sc==scriptX;
    989         }
    990 
    991         char[] scriptExtensions=UCharacterProperty.INSTANCE.m_scriptExtensions_;
    992         int scx=scriptX&UCharacterProperty.SCRIPT_MASK_;  // index into scriptExtensions
    993         if(scriptX>=UCharacterProperty.SCRIPT_X_WITH_OTHER) {
    994             scx=scriptExtensions[scx+1];
    995         }
    996         if(sc>0x7fff) {
    997             // Guard against bogus input that would
    998             // make us go past the Script_Extensions terminator.
    999             return false;
   1000         }
   1001         while(sc>scriptExtensions[scx]) {
   1002             ++scx;
   1003         }
   1004         return sc==(scriptExtensions[scx]&0x7fff);
   1005     }
   1006 
   1007     /**
   1008      * Sets code point c's Script_Extensions as script code integers into the output BitSet.
   1009      * <ul>
   1010      * <li>If c does have Script_Extensions, then the return value is
   1011      * the negative number of Script_Extensions codes (= -set.cardinality());
   1012      * in this case, the Script property value
   1013      * (normally Common or Inherited) is not included in the set.
   1014      * <li>If c does not have Script_Extensions, then the one Script code is put into the set
   1015      * and also returned.
   1016      * <li>If c is not a valid code point, then the one {@link #UNKNOWN} code is put into the set
   1017      * and also returned.
   1018      * </ul>
   1019      * In other words, if the return value is non-negative, it is c's single Script code
   1020      * and the set contains exactly this Script code.
   1021      * If the return value is -n, then the set contains c's n&gt;=2 Script_Extensions script codes.
   1022      *
   1023      * <p>Some characters are commonly used in multiple scripts.
   1024      * For more information, see UAX #24: http://www.unicode.org/reports/tr24/.
   1025      *
   1026      * @param c code point
   1027      * @param set set of script code integers; will be cleared, then bits are set
   1028      *            corresponding to c's Script_Extensions
   1029      * @return negative number of script codes in c's Script_Extensions,
   1030      *         or the non-negative single Script value
   1031      */
   1032     public static final int getScriptExtensions(int c, BitSet set) {
   1033         set.clear();
   1034         int scriptX=UCharacterProperty.INSTANCE.getAdditional(c, 0)&UCharacterProperty.SCRIPT_X_MASK;
   1035         if(scriptX<UCharacterProperty.SCRIPT_X_WITH_COMMON) {
   1036             set.set(scriptX);
   1037             return scriptX;
   1038         }
   1039 
   1040         char[] scriptExtensions=UCharacterProperty.INSTANCE.m_scriptExtensions_;
   1041         int scx=scriptX&UCharacterProperty.SCRIPT_MASK_;  // index into scriptExtensions
   1042         if(scriptX>=UCharacterProperty.SCRIPT_X_WITH_OTHER) {
   1043             scx=scriptExtensions[scx+1];
   1044         }
   1045         int length=0;
   1046         int sx;
   1047         do {
   1048             sx=scriptExtensions[scx++];
   1049             set.set(sx&0x7fff);
   1050             ++length;
   1051         } while(sx<0x8000);
   1052         // length==set.cardinality()
   1053         return -length;
   1054     }
   1055 
   1056     /**
   1057      * Returns the long Unicode script name, if there is one.
   1058      * Otherwise returns the 4-letter ISO 15924 script code.
   1059      * Returns "Malayam" given MALAYALAM.
   1060      *
   1061      * @param scriptCode int script code
   1062      * @return long script name as given in PropertyValueAliases.txt, or the 4-letter code
   1063      * @throws IllegalArgumentException if the script code is not valid
   1064      */
   1065     public static final String getName(int scriptCode){
   1066         return UCharacter.getPropertyValueName(UProperty.SCRIPT,
   1067                 scriptCode,
   1068                 UProperty.NameChoice.LONG);
   1069     }
   1070 
   1071     /**
   1072      * Returns the 4-letter ISO 15924 script code,
   1073      * which is the same as the short Unicode script name if Unicode has names for the script.
   1074      * Returns "Mlym" given MALAYALAM.
   1075      *
   1076      * @param scriptCode int script code
   1077      * @return short script name (4-letter code)
   1078      * @throws IllegalArgumentException if the script code is not valid
   1079      */
   1080     public static final String getShortName(int scriptCode){
   1081         return UCharacter.getPropertyValueName(UProperty.SCRIPT,
   1082                 scriptCode,
   1083                 UProperty.NameChoice.SHORT);
   1084     }
   1085 
   1086     /**
   1087      * Script metadata (script properties).
   1088      * See http://unicode.org/cldr/trac/browser/trunk/common/properties/scriptMetadata.txt
   1089      */
   1090     private static final class ScriptMetadata {
   1091         // 0 = NOT_ENCODED, no sample character, default false script properties.
   1092         // Bits 20.. 0: sample character
   1093 
   1094         // Bits 23..21: usage
   1095         private static final int UNKNOWN = 1 << 21;
   1096         private static final int EXCLUSION = 2 << 21;
   1097         private static final int LIMITED_USE = 3 << 21;
   1098         // vate static final int ASPIRATIONAL = 4 << 21; -- not used any more since Unicode 10
   1099         private static final int RECOMMENDED = 5 << 21;
   1100 
   1101         // Bits 31..24: Single-bit flags
   1102         private static final int RTL = 1 << 24;
   1103         private static final int LB_LETTERS = 1 << 25;
   1104         private static final int CASED = 1 << 26;
   1105 
   1106         private static final int SCRIPT_PROPS[] = {
   1107             // Begin copy-paste output from
   1108             // tools/trunk/unicode/py/parsescriptmetadata.py
   1109             // or from icu/trunk/source/common/uscript_props.cpp
   1110             0x0040 | RECOMMENDED,  // Zyyy
   1111             0x0308 | RECOMMENDED,  // Zinh
   1112             0x0628 | RECOMMENDED | RTL,  // Arab
   1113             0x0531 | RECOMMENDED | CASED,  // Armn
   1114             0x0995 | RECOMMENDED,  // Beng
   1115             0x3105 | RECOMMENDED | LB_LETTERS,  // Bopo
   1116             0x13C4 | LIMITED_USE | CASED,  // Cher
   1117             0x03E2 | EXCLUSION | CASED,  // Copt
   1118             0x042F | RECOMMENDED | CASED,  // Cyrl
   1119             0x10414 | EXCLUSION | CASED,  // Dsrt
   1120             0x0905 | RECOMMENDED,  // Deva
   1121             0x12A0 | RECOMMENDED,  // Ethi
   1122             0x10D3 | RECOMMENDED,  // Geor
   1123             0x10330 | EXCLUSION,  // Goth
   1124             0x03A9 | RECOMMENDED | CASED,  // Grek
   1125             0x0A95 | RECOMMENDED,  // Gujr
   1126             0x0A15 | RECOMMENDED,  // Guru
   1127             0x5B57 | RECOMMENDED | LB_LETTERS,  // Hani
   1128             0xAC00 | RECOMMENDED,  // Hang
   1129             0x05D0 | RECOMMENDED | RTL,  // Hebr
   1130             0x304B | RECOMMENDED | LB_LETTERS,  // Hira
   1131             0x0C95 | RECOMMENDED,  // Knda
   1132             0x30AB | RECOMMENDED | LB_LETTERS,  // Kana
   1133             0x1780 | RECOMMENDED | LB_LETTERS,  // Khmr
   1134             0x0EA5 | RECOMMENDED | LB_LETTERS,  // Laoo
   1135             0x004C | RECOMMENDED | CASED,  // Latn
   1136             0x0D15 | RECOMMENDED,  // Mlym
   1137             0x1826 | LIMITED_USE,  // Mong
   1138             0x1000 | RECOMMENDED | LB_LETTERS,  // Mymr
   1139             0x168F | EXCLUSION,  // Ogam
   1140             0x10300 | EXCLUSION,  // Ital
   1141             0x0B15 | RECOMMENDED,  // Orya
   1142             0x16A0 | EXCLUSION,  // Runr
   1143             0x0D85 | RECOMMENDED,  // Sinh
   1144             0x0710 | LIMITED_USE | RTL,  // Syrc
   1145             0x0B95 | RECOMMENDED,  // Taml
   1146             0x0C15 | RECOMMENDED,  // Telu
   1147             0x078C | RECOMMENDED | RTL,  // Thaa
   1148             0x0E17 | RECOMMENDED | LB_LETTERS,  // Thai
   1149             0x0F40 | RECOMMENDED,  // Tibt
   1150             0x14C0 | LIMITED_USE,  // Cans
   1151             0xA288 | LIMITED_USE | LB_LETTERS,  // Yiii
   1152             0x1703 | EXCLUSION,  // Tglg
   1153             0x1723 | EXCLUSION,  // Hano
   1154             0x1743 | EXCLUSION,  // Buhd
   1155             0x1763 | EXCLUSION,  // Tagb
   1156             0x280E | UNKNOWN,  // Brai
   1157             0x10800 | EXCLUSION | RTL,  // Cprt
   1158             0x1900 | LIMITED_USE,  // Limb
   1159             0x10000 | EXCLUSION,  // Linb
   1160             0x10480 | EXCLUSION,  // Osma
   1161             0x10450 | EXCLUSION,  // Shaw
   1162             0x1950 | LIMITED_USE | LB_LETTERS,  // Tale
   1163             0x10380 | EXCLUSION,  // Ugar
   1164             0,
   1165             0x1A00 | EXCLUSION,  // Bugi
   1166             0x2C00 | EXCLUSION | CASED,  // Glag
   1167             0x10A00 | EXCLUSION | RTL,  // Khar
   1168             0xA800 | LIMITED_USE,  // Sylo
   1169             0x1980 | LIMITED_USE | LB_LETTERS,  // Talu
   1170             0x2D30 | LIMITED_USE,  // Tfng
   1171             0x103A0 | EXCLUSION,  // Xpeo
   1172             0x1B05 | LIMITED_USE,  // Bali
   1173             0x1BC0 | LIMITED_USE,  // Batk
   1174             0,
   1175             0x11005 | EXCLUSION,  // Brah
   1176             0xAA00 | LIMITED_USE,  // Cham
   1177             0,
   1178             0,
   1179             0,
   1180             0,
   1181             0x13153 | EXCLUSION,  // Egyp
   1182             0,
   1183             0x5B57 | RECOMMENDED | LB_LETTERS,  // Hans
   1184             0x5B57 | RECOMMENDED | LB_LETTERS,  // Hant
   1185             0x16B1C | EXCLUSION,  // Hmng
   1186             0x10CA1 | EXCLUSION | RTL | CASED,  // Hung
   1187             0,
   1188             0xA984 | LIMITED_USE,  // Java
   1189             0xA90A | LIMITED_USE,  // Kali
   1190             0,
   1191             0,
   1192             0x1C00 | LIMITED_USE,  // Lepc
   1193             0x10647 | EXCLUSION,  // Lina
   1194             0x0840 | LIMITED_USE | RTL,  // Mand
   1195             0,
   1196             0x10980 | EXCLUSION | RTL,  // Mero
   1197             0x07CA | LIMITED_USE | RTL,  // Nkoo
   1198             0x10C00 | EXCLUSION | RTL,  // Orkh
   1199             0x1036B | EXCLUSION,  // Perm
   1200             0xA840 | EXCLUSION,  // Phag
   1201             0x10900 | EXCLUSION | RTL,  // Phnx
   1202             0x16F00 | LIMITED_USE,  // Plrd
   1203             0,
   1204             0,
   1205             0,
   1206             0,
   1207             0,
   1208             0,
   1209             0xA549 | LIMITED_USE,  // Vaii
   1210             0,
   1211             0x12000 | EXCLUSION,  // Xsux
   1212             0,
   1213             0xFDD0 | UNKNOWN,  // Zzzz
   1214             0x102A0 | EXCLUSION,  // Cari
   1215             0x304B | RECOMMENDED | LB_LETTERS,  // Jpan
   1216             0x1A20 | LIMITED_USE | LB_LETTERS,  // Lana
   1217             0x10280 | EXCLUSION,  // Lyci
   1218             0x10920 | EXCLUSION | RTL,  // Lydi
   1219             0x1C5A | LIMITED_USE,  // Olck
   1220             0xA930 | EXCLUSION,  // Rjng
   1221             0xA882 | LIMITED_USE,  // Saur
   1222             0x1D850 | EXCLUSION,  // Sgnw
   1223             0x1B83 | LIMITED_USE,  // Sund
   1224             0,
   1225             0xABC0 | LIMITED_USE,  // Mtei
   1226             0x10840 | EXCLUSION | RTL,  // Armi
   1227             0x10B00 | EXCLUSION | RTL,  // Avst
   1228             0x11103 | LIMITED_USE,  // Cakm
   1229             0xAC00 | RECOMMENDED,  // Kore
   1230             0x11083 | EXCLUSION,  // Kthi
   1231             0x10AD8 | EXCLUSION | RTL,  // Mani
   1232             0x10B60 | EXCLUSION | RTL,  // Phli
   1233             0x10B8F | EXCLUSION | RTL,  // Phlp
   1234             0,
   1235             0x10B40 | EXCLUSION | RTL,  // Prti
   1236             0x0800 | EXCLUSION | RTL,  // Samr
   1237             0xAA80 | LIMITED_USE | LB_LETTERS,  // Tavt
   1238             0,
   1239             0,
   1240             0xA6A0 | LIMITED_USE,  // Bamu
   1241             0xA4D0 | LIMITED_USE,  // Lisu
   1242             0,
   1243             0x10A60 | EXCLUSION | RTL,  // Sarb
   1244             0x16AE6 | EXCLUSION,  // Bass
   1245             0x1BC20 | EXCLUSION,  // Dupl
   1246             0x10500 | EXCLUSION,  // Elba
   1247             0x11315 | EXCLUSION,  // Gran
   1248             0,
   1249             0,
   1250             0x1E802 | EXCLUSION | RTL,  // Mend
   1251             0x109A0 | EXCLUSION | RTL,  // Merc
   1252             0x10A95 | EXCLUSION | RTL,  // Narb
   1253             0x10896 | EXCLUSION | RTL,  // Nbat
   1254             0x10873 | EXCLUSION | RTL,  // Palm
   1255             0x112BE | EXCLUSION,  // Sind
   1256             0x118B4 | EXCLUSION | CASED,  // Wara
   1257             0,
   1258             0,
   1259             0x16A4F | EXCLUSION,  // Mroo
   1260             0x1B1C4 | EXCLUSION | LB_LETTERS,  // Nshu
   1261             0x11183 | EXCLUSION,  // Shrd
   1262             0x110D0 | EXCLUSION,  // Sora
   1263             0x11680 | EXCLUSION,  // Takr
   1264             0x18229 | EXCLUSION | LB_LETTERS,  // Tang
   1265             0,
   1266             0x14400 | EXCLUSION,  // Hluw
   1267             0x11208 | EXCLUSION,  // Khoj
   1268             0x11484 | EXCLUSION,  // Tirh
   1269             0x10537 | EXCLUSION,  // Aghb
   1270             0x11152 | EXCLUSION,  // Mahj
   1271             0x11717 | EXCLUSION | LB_LETTERS,  // Ahom
   1272             0x108F4 | EXCLUSION | RTL,  // Hatr
   1273             0x1160E | EXCLUSION,  // Modi
   1274             0x1128F | EXCLUSION,  // Mult
   1275             0x11AC0 | EXCLUSION,  // Pauc
   1276             0x1158E | EXCLUSION,  // Sidd
   1277             0x1E909 | LIMITED_USE | RTL | CASED,  // Adlm
   1278             0x11C0E | EXCLUSION,  // Bhks
   1279             0x11C72 | EXCLUSION,  // Marc
   1280             0x11412 | LIMITED_USE,  // Newa
   1281             0x104B5 | LIMITED_USE | CASED,  // Osge
   1282             0x5B57 | RECOMMENDED | LB_LETTERS,  // Hanb
   1283             0x1112 | RECOMMENDED,  // Jamo
   1284             0,
   1285             0x11D10 | EXCLUSION,  // Gonm
   1286             0x11A5C | EXCLUSION,  // Soyo
   1287             0x11A0B | EXCLUSION,  // Zanb
   1288             // End copy-paste from parsescriptmetadata.py
   1289         };
   1290 
   1291         private static final int getScriptProps(int script) {
   1292             if (0 <= script && script < SCRIPT_PROPS.length) {
   1293                 return SCRIPT_PROPS[script];
   1294             } else {
   1295                 return 0;
   1296             }
   1297         }
   1298     }
   1299 
   1300     /**
   1301      * Script usage constants.
   1302      * See UAX #31 Unicode Identifier and Pattern Syntax.
   1303      * http://www.unicode.org/reports/tr31/#Table_Candidate_Characters_for_Exclusion_from_Identifiers
   1304      */
   1305     public enum ScriptUsage {
   1306         /**
   1307          * Not encoded in Unicode.
   1308          */
   1309         NOT_ENCODED,
   1310         /**
   1311          * Unknown script usage.
   1312          */
   1313         UNKNOWN,
   1314         /**
   1315          * Candidate for Exclusion from Identifiers.
   1316          */
   1317         EXCLUDED,
   1318         /**
   1319          * Limited Use script.
   1320          */
   1321         LIMITED_USE,
   1322         /**
   1323          * Aspirational Use script.
   1324          */
   1325         ASPIRATIONAL,
   1326         /**
   1327          * Recommended script.
   1328          */
   1329         RECOMMENDED
   1330     }
   1331     private static final ScriptUsage[] usageValues = ScriptUsage.values();
   1332 
   1333     /**
   1334      * Returns the script sample character string.
   1335      * This string normally consists of one code point but might be longer.
   1336      * The string is empty if the script is not encoded.
   1337      *
   1338      * @param script script code
   1339      * @return the sample character string
   1340      */
   1341     public static final String getSampleString(int script) {
   1342         int sampleChar = ScriptMetadata.getScriptProps(script) & 0x1fffff;
   1343         if(sampleChar != 0) {
   1344             return new StringBuilder().appendCodePoint(sampleChar).toString();
   1345         }
   1346         return "";
   1347     }
   1348 
   1349     /**
   1350      * Returns the script usage according to UAX #31 Unicode Identifier and Pattern Syntax.
   1351      * Returns {@link ScriptUsage#NOT_ENCODED} if the script is not encoded in Unicode.
   1352      *
   1353      * @param script script code
   1354      * @return script usage
   1355      * @see ScriptUsage
   1356      */
   1357     public static final ScriptUsage getUsage(int script) {
   1358         return usageValues[(ScriptMetadata.getScriptProps(script) >> 21) & 7];
   1359     }
   1360 
   1361     /**
   1362      * Returns true if the script is written right-to-left.
   1363      * For example, Arab and Hebr.
   1364      *
   1365      * @param script script code
   1366      * @return true if the script is right-to-left
   1367      */
   1368     public static final boolean isRightToLeft(int script) {
   1369         return (ScriptMetadata.getScriptProps(script) & ScriptMetadata.RTL) != 0;
   1370     }
   1371 
   1372     /**
   1373      * Returns true if the script allows line breaks between letters (excluding hyphenation).
   1374      * Such a script typically requires dictionary-based line breaking.
   1375      * For example, Hani and Thai.
   1376      *
   1377      * @param script script code
   1378      * @return true if the script allows line breaks between letters
   1379      */
   1380     public static final boolean breaksBetweenLetters(int script) {
   1381         return (ScriptMetadata.getScriptProps(script) & ScriptMetadata.LB_LETTERS) != 0;
   1382     }
   1383 
   1384     /**
   1385      * Returns true if in modern (or most recent) usage of the script case distinctions are customary.
   1386      * For example, Latn and Cyrl.
   1387      *
   1388      * @param script script code
   1389      * @return true if the script is cased
   1390      */
   1391     public static final boolean isCased(int script) {
   1392         return (ScriptMetadata.getScriptProps(script) & ScriptMetadata.CASED) != 0;
   1393     }
   1394 
   1395     ///CLOVER:OFF
   1396     /**
   1397      *  Private Constructor. Never default construct
   1398      */
   1399     private UScript(){}
   1400     ///CLOVER:ON
   1401 }
   1402