mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-20 20:19:32 +00:00
ICU-1721 Blocks.txt and PropList.txt -> uprops.dat
X-SVN-Rev: 7862
This commit is contained in:
parent
2f7bcf5dab
commit
071d83c3cc
4 changed files with 288 additions and 178 deletions
|
@ -880,161 +880,6 @@ u_forDigit(int32_t digit, int8_t radix) {
|
|||
|
||||
/* static data tables ------------------------------------------------------- */
|
||||
|
||||
/**********************************************************
|
||||
*
|
||||
* WARNING: The below map is machine generated
|
||||
* by genscrpt after parsing Blocks.txt,
|
||||
* plese donot edit unless you know what you are doing
|
||||
*
|
||||
**********************************************************
|
||||
*/
|
||||
|
||||
#define UBLOCK_CODE_INDEX_SIZE 98
|
||||
|
||||
struct UBlockCodeMap {
|
||||
const UChar32 fFirstCode;
|
||||
const UChar32 fLastCode;
|
||||
const UBlockCode code;
|
||||
};
|
||||
typedef struct UBlockCodeMap UBlockCodeMap;
|
||||
|
||||
static const UBlockCodeMap blockCodeIndex[UBLOCK_CODE_INDEX_SIZE] = {
|
||||
{ 0x00000000, 0x0000007F, UBLOCK_BASIC_LATIN },
|
||||
{ 0x00000080, 0x000000FF, UBLOCK_LATIN_1_SUPPLEMENT },
|
||||
{ 0x00000100, 0x0000017F, UBLOCK_LATIN_EXTENDED_A },
|
||||
{ 0x00000180, 0x0000024F, UBLOCK_LATIN_EXTENDED_B },
|
||||
{ 0x00000250, 0x000002AF, UBLOCK_IPA_EXTENSIONS },
|
||||
{ 0x000002B0, 0x000002FF, UBLOCK_SPACING_MODIFIER_LETTERS },
|
||||
{ 0x00000300, 0x0000036F, UBLOCK_COMBINING_DIACRITICAL_MARKS },
|
||||
{ 0x00000370, 0x000003FF, UBLOCK_GREEK },
|
||||
{ 0x00000400, 0x000004FF, UBLOCK_CYRILLIC },
|
||||
{ 0x00000530, 0x0000058F, UBLOCK_ARMENIAN },
|
||||
{ 0x00000590, 0x000005FF, UBLOCK_HEBREW },
|
||||
{ 0x00000600, 0x000006FF, UBLOCK_ARABIC },
|
||||
{ 0x00000700, 0x0000074F, UBLOCK_SYRIAC },
|
||||
{ 0x00000780, 0x000007BF, UBLOCK_THAANA },
|
||||
{ 0x00000900, 0x0000097F, UBLOCK_DEVANAGARI },
|
||||
{ 0x00000980, 0x000009FF, UBLOCK_BENGALI },
|
||||
{ 0x00000A00, 0x00000A7F, UBLOCK_GURMUKHI },
|
||||
{ 0x00000A80, 0x00000AFF, UBLOCK_GUJARATI },
|
||||
{ 0x00000B00, 0x00000B7F, UBLOCK_ORIYA },
|
||||
{ 0x00000B80, 0x00000BFF, UBLOCK_TAMIL },
|
||||
{ 0x00000C00, 0x00000C7F, UBLOCK_TELUGU },
|
||||
{ 0x00000C80, 0x00000CFF, UBLOCK_KANNADA },
|
||||
{ 0x00000D00, 0x00000D7F, UBLOCK_MALAYALAM },
|
||||
{ 0x00000D80, 0x00000DFF, UBLOCK_SINHALA },
|
||||
{ 0x00000E00, 0x00000E7F, UBLOCK_THAI },
|
||||
{ 0x00000E80, 0x00000EFF, UBLOCK_LAO },
|
||||
{ 0x00000F00, 0x00000FFF, UBLOCK_TIBETAN },
|
||||
{ 0x00001000, 0x0000109F, UBLOCK_MYANMAR },
|
||||
{ 0x000010A0, 0x000010FF, UBLOCK_GEORGIAN },
|
||||
{ 0x00001100, 0x000011FF, UBLOCK_HANGUL_JAMO },
|
||||
{ 0x00001200, 0x0000137F, UBLOCK_ETHIOPIC },
|
||||
{ 0x000013A0, 0x000013FF, UBLOCK_CHEROKEE },
|
||||
{ 0x00001400, 0x0000167F, UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS },
|
||||
{ 0x00001680, 0x0000169F, UBLOCK_OGHAM },
|
||||
{ 0x000016A0, 0x000016FF, UBLOCK_RUNIC },
|
||||
{ 0x00001780, 0x000017FF, UBLOCK_KHMER },
|
||||
{ 0x00001800, 0x000018AF, UBLOCK_MONGOLIAN },
|
||||
{ 0x00001E00, 0x00001EFF, UBLOCK_LATIN_EXTENDED_ADDITIONAL },
|
||||
{ 0x00001F00, 0x00001FFF, UBLOCK_GREEK_EXTENDED },
|
||||
{ 0x00002000, 0x0000206F, UBLOCK_GENERAL_PUNCTUATION },
|
||||
{ 0x00002070, 0x0000209F, UBLOCK_SUPERSCRIPTS_AND_SUBSCRIPTS },
|
||||
{ 0x000020A0, 0x000020CF, UBLOCK_CURRENCY_SYMBOLS },
|
||||
{ 0x000020D0, 0x000020FF, UBLOCK_COMBINING_MARKS_FOR_SYMBOLS },
|
||||
{ 0x00002100, 0x0000214F, UBLOCK_LETTERLIKE_SYMBOLS },
|
||||
{ 0x00002150, 0x0000218F, UBLOCK_NUMBER_FORMS },
|
||||
{ 0x00002190, 0x000021FF, UBLOCK_ARROWS },
|
||||
{ 0x00002200, 0x000022FF, UBLOCK_MATHEMATICAL_OPERATORS },
|
||||
{ 0x00002300, 0x000023FF, UBLOCK_MISCELLANEOUS_TECHNICAL },
|
||||
{ 0x00002400, 0x0000243F, UBLOCK_CONTROL_PICTURES },
|
||||
{ 0x00002440, 0x0000245F, UBLOCK_OPTICAL_CHARACTER_RECOGNITION },
|
||||
{ 0x00002460, 0x000024FF, UBLOCK_ENCLOSED_ALPHANUMERICS },
|
||||
{ 0x00002500, 0x0000257F, UBLOCK_BOX_DRAWING },
|
||||
{ 0x00002580, 0x0000259F, UBLOCK_BLOCK_ELEMENTS },
|
||||
{ 0x000025A0, 0x000025FF, UBLOCK_GEOMETRIC_SHAPES },
|
||||
{ 0x00002600, 0x000026FF, UBLOCK_MISCELLANEOUS_SYMBOLS },
|
||||
{ 0x00002700, 0x000027BF, UBLOCK_DINGBATS },
|
||||
{ 0x00002800, 0x000028FF, UBLOCK_BRAILLE_PATTERNS },
|
||||
{ 0x00002E80, 0x00002EFF, UBLOCK_CJK_RADICALS_SUPPLEMENT },
|
||||
{ 0x00002F00, 0x00002FDF, UBLOCK_KANGXI_RADICALS },
|
||||
{ 0x00002FF0, 0x00002FFF, UBLOCK_IDEOGRAPHIC_DESCRIPTION_CHARACTERS },
|
||||
{ 0x00003000, 0x0000303F, UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION },
|
||||
{ 0x00003040, 0x0000309F, UBLOCK_HIRAGANA },
|
||||
{ 0x000030A0, 0x000030FF, UBLOCK_KATAKANA },
|
||||
{ 0x00003100, 0x0000312F, UBLOCK_BOPOMOFO },
|
||||
{ 0x00003130, 0x0000318F, UBLOCK_HANGUL_COMPATIBILITY_JAMO },
|
||||
{ 0x00003190, 0x0000319F, UBLOCK_KANBUN },
|
||||
{ 0x000031A0, 0x000031BF, UBLOCK_BOPOMOFO_EXTENDED },
|
||||
{ 0x00003200, 0x000032FF, UBLOCK_ENCLOSED_CJK_LETTERS_AND_MONTHS },
|
||||
{ 0x00003300, 0x000033FF, UBLOCK_CJK_COMPATIBILITY },
|
||||
{ 0x00003400, 0x00004DB5, UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A },
|
||||
{ 0x00004E00, 0x00009FFF, UBLOCK_CJK_UNIFIED_IDEOGRAPHS },
|
||||
{ 0x0000A000, 0x0000A48F, UBLOCK_YI_SYLLABLES },
|
||||
{ 0x0000A490, 0x0000A4CF, UBLOCK_YI_RADICALS },
|
||||
{ 0x0000AC00, 0x0000D7A3, UBLOCK_HANGUL_SYLLABLES },
|
||||
{ 0x0000D800, 0x0000DB7F, UBLOCK_HIGH_SURROGATES },
|
||||
{ 0x0000DB80, 0x0000DBFF, UBLOCK_HIGH_PRIVATE_USE_SURROGATES },
|
||||
{ 0x0000DC00, 0x0000DFFF, UBLOCK_LOW_SURROGATES },
|
||||
{ 0x0000E000, 0x0000F8FF, UBLOCK_PRIVATE_USE },
|
||||
{ 0x0000F900, 0x0000FAFF, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS },
|
||||
{ 0x0000FB00, 0x0000FB4F, UBLOCK_ALPHABETIC_PRESENTATION_FORMS },
|
||||
{ 0x0000FB50, 0x0000FDFF, UBLOCK_ARABIC_PRESENTATION_FORMS_A },
|
||||
{ 0x0000FE20, 0x0000FE2F, UBLOCK_COMBINING_HALF_MARKS },
|
||||
{ 0x0000FE30, 0x0000FE4F, UBLOCK_CJK_COMPATIBILITY_FORMS },
|
||||
{ 0x0000FE50, 0x0000FE6F, UBLOCK_SMALL_FORM_VARIANTS },
|
||||
{ 0x0000FE70, 0x0000FEFE, UBLOCK_ARABIC_PRESENTATION_FORMS_B },
|
||||
{ 0x0000FEFF, 0x0000FEFF, UBLOCK_SPECIALS },
|
||||
{ 0x0000FF00, 0x0000FFEF, UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS },
|
||||
{ 0x0000FFF0, 0x0000FFFD, UBLOCK_SPECIALS },
|
||||
{ 0x00010300, 0x0001032F, UBLOCK_OLD_ITALIC },
|
||||
{ 0x00010330, 0x0001034F, UBLOCK_GOTHIC },
|
||||
{ 0x00010400, 0x0001044F, UBLOCK_DESERET },
|
||||
{ 0x0001D000, 0x0001D0FF, UBLOCK_BYZANTINE_MUSICAL_SYMBOLS },
|
||||
{ 0x0001D100, 0x0001D1FF, UBLOCK_MUSICAL_SYMBOLS },
|
||||
{ 0x0001D400, 0x0001D7FF, UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS },
|
||||
{ 0x00020000, 0x0002A6D6, UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B },
|
||||
{ 0x0002F800, 0x0002FA1F, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT },
|
||||
{ 0x000E0000, 0x000E007F, UBLOCK_TAGS },
|
||||
{ 0x000F0000, 0x000FFFFD, UBLOCK_PRIVATE_USE },
|
||||
};
|
||||
|
||||
/* Get the script associated with the character*/
|
||||
U_CAPI UBlockCode U_EXPORT2
|
||||
ublock_getCode(UChar32 codepoint)
|
||||
{
|
||||
/* binary search the map and return the code */
|
||||
int32_t left, middle, right,rc;
|
||||
|
||||
left =0;
|
||||
right= UBLOCK_CODE_INDEX_SIZE-1;
|
||||
|
||||
while(left <= right){
|
||||
middle = (left+right)/2;
|
||||
/* check if the codepoint is the valid range */
|
||||
if((uint32_t)(blockCodeIndex[middle].fLastCode - codepoint) <=
|
||||
(blockCodeIndex[middle].fLastCode - blockCodeIndex[middle].fFirstCode)
|
||||
){
|
||||
rc = 0;
|
||||
}else if(codepoint> blockCodeIndex[middle].fLastCode){
|
||||
rc =-1;
|
||||
}else {
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
if(rc<0){
|
||||
left = middle+1;
|
||||
}else if(rc >0){
|
||||
right = middle -1;
|
||||
}else{
|
||||
return blockCodeIndex[middle].code;
|
||||
}
|
||||
}
|
||||
return UBLOCK_INVALID_CODE;
|
||||
}
|
||||
|
||||
/******************************************************/
|
||||
|
||||
static const UChar cellWidthRanges[] =
|
||||
{
|
||||
0x0000, /* general scripts area*/
|
||||
|
|
|
@ -44,3 +44,19 @@ uscript_getScript(UChar32 c, UErrorCode *pErrorCode) {
|
|||
|
||||
return (UScriptCode)(u_getUnicodeProperties(c, 0)&UPROPS_SCRIPT_MASK);
|
||||
}
|
||||
|
||||
U_CAPI UBlockCode U_EXPORT2
|
||||
ublock_getCode(UChar32 c) {
|
||||
uint32_t b;
|
||||
|
||||
if((uint32_t)c>0x10ffff) {
|
||||
return UBLOCK_INVALID_CODE;
|
||||
}
|
||||
|
||||
b=(u_getUnicodeProperties(c, 0)&UPROPS_BLOCK_MASK)>>UPROPS_BLOCK_SHIFT;
|
||||
if(b==0) {
|
||||
return UBLOCK_INVALID_CODE;
|
||||
} else {
|
||||
return (UBlockCode)b;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,12 +49,47 @@ enum {
|
|||
#define UPROPS_AGE_MASK 0xff000000
|
||||
#define UPROPS_AGE_SHIFT 24
|
||||
|
||||
#define UPROPS_SCRIPT_MASK 0x7f
|
||||
#define UPROPS_BLOCK_MASK 0x00007f80
|
||||
#define UPROPS_BLOCK_SHIFT 7
|
||||
|
||||
#define UPROPS_SCRIPT_MASK 0x0000007f
|
||||
|
||||
/*
|
||||
* Properties in vector word 1
|
||||
* Bits
|
||||
* Each bit encodes one binary property.
|
||||
* The following constants represent the bit number, use 1<<UPROPS_XYZ.
|
||||
* UPROPS_BINARY_1_TOP<=32!
|
||||
*/
|
||||
enum {
|
||||
UPROPS_WHITE_SPACE,
|
||||
UPROPS_BIDI_CONTROL,
|
||||
UPROPS_JOIN_CONTROL,
|
||||
UPROPS_DASH,
|
||||
UPROPS_HYPHEN,
|
||||
UPROPS_QUOTATION_MARK,
|
||||
UPROPS_TERMINAL_PUNCTUATION,
|
||||
UPROPS_OTHER_MATH,
|
||||
UPROPS_HEX_DIGIT,
|
||||
UPROPS_ASCII_HEX_DIGIT,
|
||||
UPROPS_OTHER_ALPHABETIC,
|
||||
UPROPS_IDEOGRAPHIC,
|
||||
UPROPS_DIACRITIC,
|
||||
UPROPS_EXTENDER,
|
||||
UPROPS_OTHER_LOWERCASE,
|
||||
UPROPS_OTHER_UPPERCASE,
|
||||
UPROPS_NONCHARACTER_CODE_POINT,
|
||||
UPROPS_OTHER_GRAPHEME_EXTEND,
|
||||
UPROPS_GRAPHEME_LINK,
|
||||
UPROPS_IDS_BINARY_OPERATOR,
|
||||
UPROPS_IDS_TRINARY_OPERATOR,
|
||||
UPROPS_RADICAL,
|
||||
UPROPS_UNIFIED_IDEOGRAPH,
|
||||
UPROPS_OTHER_DEFAULT_IGNORABLE_CODE_POINT,
|
||||
UPROPS_DEPRECATED,
|
||||
UPROPS_SOFT_DOTTED,
|
||||
UPROPS_LOGICAL_ORDER_EXCEPTION,
|
||||
UPROPS_BINARY_1_TOP
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a properties vector word for a code point.
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uchar.h"
|
||||
#include "unicode/uscript.h"
|
||||
#include "cstring.h"
|
||||
#include "cmemory.h"
|
||||
|
@ -37,10 +38,28 @@ static int32_t pvCount;
|
|||
/* prototypes --------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
parseAge(const char *filename, uint32_t *pv, UErrorCode *pErrorCode);
|
||||
parseTwoFieldFile(char *filename, char *basename,
|
||||
const char *ucdFile, const char *suffix,
|
||||
UParseLineFn *lineFn,
|
||||
UErrorCode *pErrorCode);
|
||||
|
||||
static void
|
||||
parseScripts(const char *filename, uint32_t *pv, UErrorCode *pErrorCode);
|
||||
ageLineFn(void *context,
|
||||
char *fields[][2], int32_t fieldCount,
|
||||
UErrorCode *pErrorCode);
|
||||
|
||||
static void
|
||||
parseScripts(const char *filename, UErrorCode *pErrorCode);
|
||||
|
||||
static void
|
||||
blocksLineFn(void *context,
|
||||
char *fields[][2], int32_t fieldCount,
|
||||
UErrorCode *pErrorCode);
|
||||
|
||||
static void
|
||||
propListLineFn(void *context,
|
||||
char *fields[][2], int32_t fieldCount,
|
||||
UErrorCode *pErrorCode);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -53,11 +72,14 @@ generateAdditionalProperties(char *filename, const char *suffix, UErrorCode *pEr
|
|||
pv=upvec_open(UPROPS_VECTOR_WORDS, 20000);
|
||||
|
||||
/* process various UCD .txt files */
|
||||
writeUCDFilename(basename, "DerivedAge", suffix);
|
||||
parseAge(filename, pv, pErrorCode);
|
||||
parseTwoFieldFile(filename, basename, "DerivedAge", suffix, ageLineFn, pErrorCode);
|
||||
|
||||
writeUCDFilename(basename, "Scripts", suffix);
|
||||
parseScripts(filename, pv, pErrorCode);
|
||||
parseScripts(filename, pErrorCode);
|
||||
|
||||
parseTwoFieldFile(filename, basename, "Blocks", suffix, blocksLineFn, pErrorCode);
|
||||
|
||||
parseTwoFieldFile(filename, basename, "PropList", suffix, propListLineFn, pErrorCode);
|
||||
|
||||
trie=utrie_open(NULL, NULL, 50000, 0, FALSE);
|
||||
if(trie==NULL) {
|
||||
|
@ -73,13 +95,28 @@ generateAdditionalProperties(char *filename, const char *suffix, UErrorCode *pEr
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
parseTwoFieldFile(char *filename, char *basename,
|
||||
const char *ucdFile, const char *suffix,
|
||||
UParseLineFn *lineFn,
|
||||
UErrorCode *pErrorCode) {
|
||||
char *fields[2][2];
|
||||
|
||||
writeUCDFilename(basename, ucdFile, suffix);
|
||||
|
||||
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
u_parseDelimitedFile(filename, ';', fields, 2, lineFn, NULL, pErrorCode);
|
||||
}
|
||||
|
||||
/* DerivedAge.txt ----------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
ageLineFn(void *context,
|
||||
char *fields[][2], int32_t fieldCount,
|
||||
UErrorCode *pErrorCode) {
|
||||
uint32_t *pv=(uint32_t *)context;
|
||||
char *s, *end;
|
||||
uint32_t value, start, limit, version;
|
||||
|
||||
|
@ -118,24 +155,12 @@ ageLineFn(void *context,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
parseAge(const char *filename, uint32_t *pv, UErrorCode *pErrorCode) {
|
||||
char *fields[2][2];
|
||||
|
||||
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
u_parseDelimitedFile(filename, ';', fields, 2, ageLineFn, pv, pErrorCode);
|
||||
}
|
||||
|
||||
/* Scripts.txt -------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
scriptsLineFn(void *context,
|
||||
char *fields[][2], int32_t fieldCount,
|
||||
UErrorCode *pErrorCode) {
|
||||
uint32_t *pv=(uint32_t *)context;
|
||||
char *s, *end;
|
||||
uint32_t start, limit;
|
||||
UScriptCode script;
|
||||
|
@ -160,7 +185,7 @@ scriptsLineFn(void *context,
|
|||
U_FAILURE(*pErrorCode) ||
|
||||
script<=USCRIPT_INVALID_CODE
|
||||
) {
|
||||
fprintf(stderr, "genprops: syntax error in Scripts.txt field 1 at %s\n", fields[1][0]);
|
||||
fprintf(stderr, "genprops error: unknown script name in Scripts.txt field 1 at %s\n", fields[1][0]);
|
||||
if(U_SUCCESS(*pErrorCode)) {
|
||||
*pErrorCode=U_PARSE_ERROR;
|
||||
}
|
||||
|
@ -174,7 +199,7 @@ scriptsLineFn(void *context,
|
|||
}
|
||||
|
||||
static void
|
||||
parseScripts(const char *filename, uint32_t *pv, UErrorCode *pErrorCode) {
|
||||
parseScripts(const char *filename, UErrorCode *pErrorCode) {
|
||||
char *fields[2][2];
|
||||
|
||||
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
|
||||
|
@ -198,7 +223,196 @@ parseScripts(const char *filename, uint32_t *pv, UErrorCode *pErrorCode) {
|
|||
exit(*pErrorCode);
|
||||
}
|
||||
|
||||
u_parseDelimitedFile(filename, ';', fields, 2, scriptsLineFn, pv, pErrorCode);
|
||||
u_parseDelimitedFile(filename, ';', fields, 2, scriptsLineFn, NULL, pErrorCode);
|
||||
}
|
||||
|
||||
/* Blocks.txt --------------------------------------------------------------- */
|
||||
|
||||
/* Blocks.txt block names in the order of the parallel UBlockCode constants */
|
||||
static const char *const
|
||||
blockNames[UBLOCK_COUNT]={
|
||||
NULL, /* 0 */
|
||||
"Basic Latin",
|
||||
"Latin-1 Supplement",
|
||||
"Latin Extended-A",
|
||||
"Latin Extended-B",
|
||||
"IPA Extensions",
|
||||
"Spacing Modifier Letters",
|
||||
"Combining Diacritical Marks",
|
||||
"Greek",
|
||||
"Cyrillic",
|
||||
"Armenian", /* 10 */
|
||||
"Hebrew",
|
||||
"Arabic",
|
||||
"Syriac ",
|
||||
"Thaana",
|
||||
"Devanagari",
|
||||
"Bengali",
|
||||
"Gurmukhi",
|
||||
"Gujarati",
|
||||
"Oriya",
|
||||
"Tamil", /* 20 */
|
||||
"Telugu",
|
||||
"Kannada",
|
||||
"Malayalam",
|
||||
"Sinhala",
|
||||
"Thai",
|
||||
"Lao",
|
||||
"Tibetan",
|
||||
"Myanmar ",
|
||||
"Georgian",
|
||||
"Hangul Jamo", /* 30 */
|
||||
"Ethiopic",
|
||||
"Cherokee",
|
||||
"Unified Canadian Aboriginal Syllabics",
|
||||
"Ogham",
|
||||
"Runic",
|
||||
"Khmer",
|
||||
"Mongolian",
|
||||
"Latin Extended Additional",
|
||||
"Greek Extended",
|
||||
"General Punctuation", /* 40 */
|
||||
"Superscripts and Subscripts",
|
||||
"Currency Symbols",
|
||||
"Combining Marks for Symbols",
|
||||
"Letterlike Symbols",
|
||||
"Number Forms",
|
||||
"Arrows",
|
||||
"Mathematical Operators",
|
||||
"Miscellaneous Technical",
|
||||
"Control Pictures",
|
||||
"Optical Character Recognition", /* 50 */
|
||||
"Enclosed Alphanumerics",
|
||||
"Box Drawing",
|
||||
"Block Elements",
|
||||
"Geometric Shapes",
|
||||
"Miscellaneous Symbols",
|
||||
"Dingbats",
|
||||
"Braille Patterns",
|
||||
"CJK Radicals Supplement",
|
||||
"Kangxi Radicals",
|
||||
"Ideographic Description Characters", /* 60 */
|
||||
"CJK Symbols and Punctuation",
|
||||
"Hiragana",
|
||||
"Katakana",
|
||||
"Bopomofo",
|
||||
"Hangul Compatibility Jamo",
|
||||
"Kanbun",
|
||||
"Bopomofo Extended",
|
||||
"Enclosed CJK Letters and Months",
|
||||
"CJK Compatibility",
|
||||
"CJK Unified Ideographs Extension A", /* 70 */
|
||||
"CJK Unified Ideographs",
|
||||
"Yi Syllables",
|
||||
"Yi Radicals",
|
||||
"Hangul Syllables",
|
||||
"High Surrogates",
|
||||
"High Private Use Surrogates",
|
||||
"Low Surrogates",
|
||||
"Private Use",
|
||||
"CJK Compatibility Ideographs",
|
||||
"Alphabetic Presentation Forms", /* 80 */
|
||||
"Arabic Presentation Forms-A",
|
||||
"Combining Half Marks",
|
||||
"CJK Compatibility Forms",
|
||||
"Small Form Variants",
|
||||
"Arabic Presentation Forms-B",
|
||||
"Specials",
|
||||
"Halfwidth and Fullwidth Forms",
|
||||
"Old Italic",
|
||||
"Gothic",
|
||||
"Deseret", /* 90 */
|
||||
"Byzantine Musical Symbols",
|
||||
"Musical Symbols",
|
||||
"Mathematical Alphanumeric Symbols",
|
||||
"CJK Unified Ideographs Extension B",
|
||||
"CJK Compatibility Ideographs Supplement",
|
||||
"Tags"
|
||||
};
|
||||
|
||||
static void
|
||||
blocksLineFn(void *context,
|
||||
char *fields[][2], int32_t fieldCount,
|
||||
UErrorCode *pErrorCode) {
|
||||
uint32_t start, limit;
|
||||
int32_t i;
|
||||
|
||||
u_parseCodePointRange(fields[0][0], &start, &limit, pErrorCode);
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
fprintf(stderr, "genprops: syntax error in Blocks.txt field 0 at %s\n", fields[0][0]);
|
||||
exit(*pErrorCode);
|
||||
}
|
||||
++limit;
|
||||
|
||||
/* parse block name */
|
||||
i=getTokenIndex(blockNames, UBLOCK_COUNT, fields[1][0]);
|
||||
if(i<0) {
|
||||
fprintf(stderr, "genprops error: unknown block name \"%s\" in Blocks.txt\n", fields[1][0]);
|
||||
*pErrorCode=U_PARSE_ERROR;
|
||||
exit(U_PARSE_ERROR);
|
||||
}
|
||||
|
||||
if(!upvec_setValue(pv, start, limit, 0, (uint32_t)i<<UPROPS_BLOCK_SHIFT, UPROPS_BLOCK_MASK, pErrorCode)) {
|
||||
fprintf(stderr, "genprops: unable to set block code: %s\n", u_errorName(*pErrorCode));
|
||||
exit(*pErrorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/* PropList.txt ------------------------------------------------------------- */
|
||||
|
||||
static const char *const
|
||||
propListNames[]={
|
||||
"White_Space",
|
||||
"Bidi_Control",
|
||||
"Join_Control",
|
||||
"Dash",
|
||||
"Hyphen",
|
||||
"Quotation_Mark",
|
||||
"Terminal_Punctuation",
|
||||
"Other_Math",
|
||||
"Hex_Digit",
|
||||
"ASCII_Hex_Digit",
|
||||
"Other_Alphabetic",
|
||||
"Ideographic",
|
||||
"Diacritic",
|
||||
"Extender",
|
||||
"Other_Lowercase",
|
||||
"Other_Uppercase",
|
||||
"Noncharacter_Code_Point",
|
||||
"Other_Grapheme_Extend",
|
||||
"Grapheme_Link",
|
||||
"IDS_Binary_Operator",
|
||||
"IDS_Trinary_Operator",
|
||||
"Radical",
|
||||
"Unified_Ideograph",
|
||||
"Other_Default_Ignorable_Code_Point",
|
||||
"Deprecated",
|
||||
"Soft_Dotted",
|
||||
"Logical_Order_Exception"
|
||||
};
|
||||
|
||||
static void
|
||||
propListLineFn(void *context,
|
||||
char *fields[][2], int32_t fieldCount,
|
||||
UErrorCode *pErrorCode) {
|
||||
uint32_t start, limit;
|
||||
int32_t i;
|
||||
|
||||
u_parseCodePointRange(fields[0][0], &start, &limit, pErrorCode);
|
||||
if(U_FAILURE(*pErrorCode)) {
|
||||
fprintf(stderr, "genprops: syntax error in PropList.txt field 0 at %s\n", fields[0][0]);
|
||||
exit(*pErrorCode);
|
||||
}
|
||||
++limit;
|
||||
|
||||
/* parse binary property name */
|
||||
i=getTokenIndex(propListNames, sizeof(propListNames)/sizeof(*propListNames), fields[1][0]);
|
||||
if(i<0) {
|
||||
fprintf(stderr, "genprops warning: unknown binary property name \"%s\" in PropList.txt\n", fields[1][0]);
|
||||
} else if(!upvec_setValue(pv, start, limit, 1, (uint32_t)(1<<i), (uint32_t)(1<<i), pErrorCode)) {
|
||||
fprintf(stderr, "genprops: unable to set binary property: %s\n", u_errorName(*pErrorCode));
|
||||
exit(*pErrorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/* data serialization ------------------------------------------------------- */
|
||||
|
|
Loading…
Add table
Reference in a new issue