text
stringlengths
0
601k
let kSpoofingVariant = KSpoofingVariant , o_string
let kSrc_NushuDuben = KSrc_NushuDuben , o_string
let kStrange = KStrange , o_string
let kTGH = KTGH , o_string
let kTGHZ2013 = KTGHZ2013 , o_string
let kTGT_MergedSrc = KTGT_MergedSrc , o_string
let kTaiwanTelegraph = KTaiwanTelegraph , o_string
let kTang = KTang , o_string
let kTotalStrokes = KTotalStrokes , o_string
let kTraditionalVariant = KTraditionalVariant , o_string
let kUnihanCore2020 = KUnihanCore2020 , o_string
let kVietnamese = KVietnamese , o_string
let kWubi = KWubi , o_string
let kXHC1983 = KXHC1983 , o_string
let kXerox = KXerox , o_string
let kZVariant = KZVariant , o_string
type block = ( cp * cp ) * string
type named_sequence = string * cp list
type normalization_correction = cp * cp list * cp list * ( int * int * int )
type standardized_variant = cp list * string * [ ` Isolate | ` Initial | ` Medial | ` Final ] list
type cjk_radical = string * cp * cp
type emoji_source = cp list * int option * int option * int option
type t = { description : string ; repertoire : props Cpmap . t ; blocks : block list ; named_sequences : named_sequence list ; provisional_named_sequences : named_sequence list ; normalization_corrections : normalization_correction list ; standardized_variants : standardized_variant list ; cjk_radicals : cjk_radical list ; emoji_sources : emoji_source list ; }
let cp_props db cp = try Some ( Cpmap . find cp db . repertoire ) with Not_found -> None
let cp_prop db cp p = try find ( Cpmap . find cp db . repertoire ) p
let n_block = ( ns_ucd , " block " )
let n_blocks = ( ns_ucd , " blocks " )
let n_char = ( ns_ucd , " char " )
let n_cjk_radical = ( ns_ucd , " cjk - radical " )
let n_cjk_radicals = ( ns_ucd , " cjk - radicals " )
let n_description = ( ns_ucd , " description " )
let n_emoji_source = ( ns_ucd , " emoji - source " )
let n_emoji_sources = ( ns_ucd , " emoji - sources " )
let n_group = ( ns_ucd , " group " )
let n_name_alias = ( ns_ucd , " name - alias " )
let n_named_sequence = ( ns_ucd , " named - sequence " )
let n_named_sequences = ( ns_ucd , " named - sequences " )
let n_noncharacter = ( ns_ucd , " noncharacter " )
let n_normalization_correction = ( ns_ucd , " normalization - correction " )
let n_normalization_corrections = ( ns_ucd , " normalization - corrections " )
let n_provisional_named_sequences = ( ns_ucd , " provisional - named - sequences " )
let n_repertoire = ( ns_ucd , " repertoire " )
let n_reserved = ( ns_ucd , " reserved " )
let n_standardized_variant = ( ns_ucd , " standardized - variant " )
let n_standardized_variants = ( ns_ucd , " standardized - variants " )
let n_surrogate = ( ns_ucd , " surrogate " )
let n_ucd = ( ns_ucd , " ucd " )
let add_prop : value Pmap . t -> Xmlm . attribute -> value Pmap . t = let h = Hashtbl . create 500 in let map = Hashtbl . add h in map " AHex " ( Ascii_hex_digit , i_bool ) ; map " Alpha " ( Alphabetic , i_bool ) ; map " Bidi_C " ( Bidi_control , i_bool ) ; map " Bidi_M " ( Bidi_mirrored , i_bool ) ; map " Cased " ( Cased , i_bool ) ; map " CI " ( Case_ignorable , i_bool ) ; map " CE " ( Composition_exclusion , i_bool ) ; map " CWCF " ( Changes_when_casefolded , i_bool ) ; map " CWCM " ( Changes_when_casemapped , i_bool ) ; map " CWL " ( Changes_when_lowercased , i_bool ) ; map " CWKCF " ( Changes_when_nfkc_casefolded , i_bool ) ; map " CWT " ( Changes_when_titlecased , i_bool ) ; map " CWU " ( Changes_when_uppercased , i_bool ) ; map " Comp_Ex " ( Full_composition_exclusion , i_bool ) ; map " DI " ( Default_ignorable_code_point , i_bool ) ; map " Dash " ( Dash , i_bool ) ; map " Dep " ( Deprecated , i_bool ) ; map " Dia " ( Diacritic , i_bool ) ; map " EqUIdeo " ( Equivalent_unified_ideograph , i_cp_opt ) ; map " Ext " ( Extender , i_bool ) ; map " FC_NFKC " ( Fc_nfkc_closure , i_cps_map ~ empty : false ) ; map " GCB " ( Grapheme_cluster_break , i_grapheme_cluster_break ) ; map " Gr_Base " ( Grapheme_base , i_bool ) ; map " Gr_Ext " ( Grapheme_extend , i_bool ) ; map " Gr_Link " ( Grapheme_link , i_bool ) ; map " Hex " ( Hex_digit , i_bool ) ; map " Hyphen " ( Hyphen , i_bool ) ; map " IDC " ( Id_continue , i_bool ) ; map " IDS " ( Id_start , i_bool ) ; map " IDSB " ( Ids_binary_operator , i_bool ) ; map " IDST " ( Ids_trinary_operator , i_bool ) ; map " Ideo " ( Ideographic , i_bool ) ; map " InSC " ( Indic_syllabic_category , i_indic_syllabic_category ) ; map " InMC " ( Indic_matra_category , i_indic_matra_category ) ; map " InPC " ( Indic_positional_category , i_indic_positional_category ) ; map " JSN " ( Jamo_short_name , i_string ) ; map " Join_C " ( Join_control , i_bool ) ; map " LOE " ( Logical_order_exception , i_bool ) ; map " Lower " ( Lowercase , i_bool ) ; map " Math " ( Math , i_bool ) ; map " NChar " ( Noncharacter_code_point , i_bool ) ; map " NFC_QC " ( Nfc_quick_check , i_bool_maybe ) ; map " NFD_QC " ( Nfd_quick_check , i_bool_maybe ) ; map " NFKC_QC " ( Nfkc_quick_check , i_bool_maybe ) ; map " NFKC_CF " ( Nfkc_casefold , i_cps_map ~ empty : true ) ; map " NFKD_QC " ( Nfkd_quick_check , i_bool_maybe ) ; map " OAlpha " ( Other_alphabetic , i_bool ) ; map " ODI " ( Other_default_ignorable_code_point , i_bool ) ; map " OGr_Ext " ( Other_grapheme_extend , i_bool ) ; map " OIDC " ( Other_id_continue , i_bool ) ; map " OIDS " ( Other_id_start , i_bool ) ; map " OLower " ( Other_lowercase , i_bool ) ; map " OMath " ( Other_math , i_bool ) ; map " OUpper " ( Other_uppercase , i_bool ) ; map " Pat_Syn " ( Pattern_syntax , i_bool ) ; map " Pat_WS " ( Pattern_white_space , i_bool ) ; map " PCM " ( Prepended_concatenation_mark , i_bool ) ; map " QMark " ( Quotation_mark , i_bool ) ; map " Radical " ( Radical , i_bool ) ; map " RI " ( Regional_indicator , i_bool ) ; map " SB " ( Sentence_break , i_sentence_break ) ; map " SD " ( Soft_dotted , i_bool ) ; map " STerm " ( Sterm , i_bool ) ; map " Term " ( Terminal_punctuation , i_bool ) ; map " UIdeo " ( Unified_ideograph , i_bool ) ; map " Upper " ( Uppercase , i_bool ) ; map " VS " ( Variation_selector , i_bool ) ; map " vo " ( Vertical_orientation , i_vertical_orientation ) ; map " WB " ( Word_break , i_word_break ) ; map " WSpace " ( White_space , i_bool ) ; map " XIDC " ( Xid_continue , i_bool ) ; map " XIDS " ( Xid_start , i_bool ) ; map " XO_NFC " ( Expands_on_nfc , i_bool ) ; map " XO_NFD " ( Expands_on_nfd , i_bool ) ; map " XO_NFKC " ( Expands_on_nfkc , i_bool ) ; map " XO_NFKD " ( Expands_on_nfkd , i_bool ) ; map " age " ( Age , i_age ) ; map " bc " ( Bidi_class , i_bidi_class ) ; map " blk " ( Block , i_block ) ; map " bmg " ( Bidi_mirroring_glyph , i_cp_opt ) ; map " bpb " ( Bidi_paired_bracket , i_cp_map ) ; map " bpt " ( Bidi_paired_bracket_type , i_bidi_paired_bracket_type ) ; map " ccc " ( Canonical_combining_class , i_int ) ; map " cf " ( Case_folding , i_cps_map ~ empty : false ) ; map " dm " ( Decomposition_mapping , ( i_cps_map ~ empty : true ) ) ; map " dt " ( Decomposition_type , i_decomposition_type ) ; map " ea " ( East_asian_width , i_east_asian_width ) ; map " Emoji " ( Emoji , i_bool ) ; map " EPres " ( Emoji_presentation , i_bool ) ; map " EMod " ( Emoji_modifier , i_bool ) ; map " EBase " ( Emoji_modifier_base , i_bool ) ; map " EComp " ( Emoji_component , i_bool ) ; map " ExtPict " ( Extended_pictographic , i_bool ) ; map " gc " ( General_category , i_general_category ) ; map " hst " ( Hangul_syllable_type , i_hangul_syllable_type ) ; map " isc " ( Iso_comment , i_string ) ; map " jg " ( Joining_group , i_joining_group ) ; map " jt " ( Joining_type , i_joining_type ) ; map " lb " ( Line_break , i_line_break ) ; map " lc " ( Lowercase_mapping , i_cps_map ~ empty : false ) ; map " na " ( Name , i_name ) ; map " na1 " ( Unicode_1_name , i_string ) ; map " nt " ( Numeric_type , i_numeric_type ) ; map " nv " ( Numeric_value , i_numeric_value ) ; map " sc " ( Script , i_script ) ; map " scf " ( Simple_case_folding , i_cp_map ) ; map " scx " ( Script_extensions , i_script_seq ) ; map " slc " ( Simple_lowercase_mapping , i_cp_map ) ; map " stc " ( Simple_titlecase_mapping , i_cp_map ) ; map " suc " ( Simple_uppercase_mapping , i_cp_map ) ; map " tc " ( Titlecase_mapping , i_cps_map ~ empty : false ) ; map " uax_42_element " ( UAX_42_element , i_uax_42_element ) ; map " uc " ( Uppercase_mapping , i_cps_map ~ empty : false ) ; map " kAccountingNumeric " ( KAccountingNumeric , i_string ) ; map " kAlternateHanYu " ( KAlternateHanYu , i_string ) ; map " kAlternateJEF " ( KAlternateJEF , i_string ) ; map " kAlternateKangXi " ( KAlternateKangXi , i_string ) ; map " kAlternateMorohashi " ( KAlternateMorohashi , i_string ) ; map " kBigFive " ( KBigFive , i_string ) ; map " kCCCII " ( KCCCII , i_string ) ; map " kCNS1986 " ( KCNS1986 , i_string ) ; map " kCNS1992 " ( KCNS1992 , i_string ) ; map " kCangjie " ( KCangjie , i_string ) ; map " kCantonese " ( KCantonese , i_string ) ; map " kCheungBauer " ( KCheungBauer , i_string ) ; map " kCheungBauerIndex " ( KCheungBauerIndex , i_string ) ; map " kCihaiT " ( KCihaiT , i_string ) ; map " kCompatibilityVariant " ( KCompatibilityVariant , i_string ) ; map " kCowles " ( KCowles , i_string ) ; map " kDaeJaweon " ( KDaeJaweon , i_string ) ; map " kDefinition " ( KDefinition , i_string ) ; map " kEACC " ( KEACC , i_string ) ; map " kFenn " ( KFenn , i_string ) ; map " kFennIndex " ( KFennIndex , i_string ) ; map " kFourCornerCode " ( KFourCornerCode , i_string ) ; map " kFrequency " ( KFrequency , i_string ) ; map " kGB0 " ( KGB0 , i_string ) ; map " kGB1 " ( KGB1 , i_string ) ; map " kGB3 " ( KGB3 , i_string ) ; map " kGB5 " ( KGB5 , i_string ) ; map " kGB7 " ( KGB7 , i_string ) ; map " kGB8 " ( KGB8 , i_string ) ; map " kGSR " ( KGSR , i_string ) ; map " kGradeLevel " ( KGradeLevel , i_string ) ; map " kHDZRadBreak " ( KHDZRadBreak , i_string ) ; map " kHKGlyph " ( KHKGlyph , i_string ) ; map " kHKSCS " ( KHKSCS , i_string ) ; map " kHanYu " ( KHanYu , i_string ) ; map " kHangul " ( KHangul , i_string ) ; map " kHanyuPinlu " ( KHanyuPinlu , i_string ) ; map " kHanyuPinyin " ( KHanyuPinyin , i_string ) ; map " kIBMJapan " ( KIBMJapan , i_string ) ; map " kIICore " ( KIICore , i_string ) ; map " kIRGDaeJaweon " ( KIRGDaeJaweon , i_string ) ; map " kIRGDaiKanwaZiten " ( KIRGDaiKanwaZiten , i_string ) ; map " kIRGHanyuDaZidian " ( KIRGHanyuDaZidian , i_string ) ; map " kIRGKangXi " ( KIRGKangXi , i_string ) ; map " kIRG_GSource " ( KIRG_GSource , i_string ) ; map " kIRG_HSource " ( KIRG_HSource , i_string ) ; map " kIRG_JSource " ( KIRG_JSource , i_string ) ; map " kIRG_KPSource " ( KIRG_KPSource , i_string ) ; map " kIRG_KSource " ( KIRG_KSource , i_string ) ; map " kIRG_MSource " ( KIRG_MSource , i_string ) ; map " kIRG_SSource " ( KIRG_SSource , i_string ) ; map " kIRG_TSource " ( KIRG_TSource , i_string ) ; map " kIRG_USource " ( KIRG_USource , i_string ) ; map " kIRG_UKSource " ( KIRG_UKSource , i_string ) ; map " kIRG_VSource " ( KIRG_VSource , i_string ) ; map " kJHJ " ( KJHJ , i_string ) ; map " kJIS0213 " ( KJIS0213 , i_string ) ; map " kJa " ( KJa , i_string ) ; map " kJapaneseKun " ( KJapaneseKun , i_string ) ; map " kJapaneseOn " ( KJapaneseOn , i_string ) ; map " kJinmeiyoKanji " ( KJinmeiyoKanji , i_string ) ; map " kJis0 " ( KJis0 , i_string ) ; map " kJis1 " ( KJis1 , i_string ) ; map " kJoyoKanji " ( KJoyoKanji , i_string ) ; map " kKPS0 " ( KKPS0 , i_string ) ; map " kKPS1 " ( KKPS1 , i_string ) ; map " kKSC0 " ( KKSC0 , i_string ) ; map " kKSC1 " ( KKSC1 , i_string ) ; map " kKangXi " ( KKangXi , i_string ) ; map " kKarlgren " ( KKarlgren , i_string ) ; map " kKorean " ( KKorean , i_string ) ; map " kKoreanEducationHanja " ( KKoreanEducationHanja , i_string ) ; map " kKoreanName " ( KKoreanName , i_string ) ; map " kLau " ( KLau , i_string ) ; map " kMainlandTelegraph " ( KMainlandTelegraph , i_string ) ; map " kMandarin " ( KMandarin , i_string ) ; map " kMatthews " ( KMatthews , i_string ) ; map " kMeyerWempe " ( KMeyerWempe , i_string ) ; map " kMorohashi " ( KMorohashi , i_string ) ; map " kNelson " ( KNelson , i_string ) ; map " kOtherNumeric " ( KOtherNumeric , i_string ) ; map " kPhonetic " ( KPhonetic , i_string ) ; map " kPrimaryNumeric " ( KPrimaryNumeric , i_string ) ; map " kPseudoGB1 " ( KPseudoGB1 , i_string ) ; map " kRSAdobe_Japan1_6 " ( KRSAdobe_Japan1_6 , i_string ) ; map " kRSJapanese " ( KRSJapanese , i_string ) ; map " kRSKanWa " ( KRSKanWa , i_string ) ; map " kRSKangXi " ( KRSKangXi , i_string ) ; map " kRSKorean " ( KRSKorean , i_string ) ; map " kRSMerged " ( KRSMerged , i_string ) ; map " kRSTUnicode " ( KRSTUnicode , i_string ) ; map " kRSUnicode " ( KRSUnicode , i_string ) ; map " kReading " ( KReading , i_string ) ; map " kSBGY " ( KSBGY , i_string ) ; map " kSemanticVariant " ( KSemanticVariant , i_string ) ; map " kSimplifiedVariant " ( KSimplifiedVariant , i_string ) ; map " kSpecializedSemanticVariant " ( KSpecializedSemanticVariant , i_string ) ; map " kSpoofingVariant " ( KSpoofingVariant , i_string ) ; map " kSrc_NushuDuben " ( KSrc_NushuDuben , i_string ) ; map " kTGH " ( KTGH , i_string ) ; map " kTGHZ2013 " ( KTGHZ2013 , i_string ) ; map " kTGT_MergedSrc " ( KTGT_MergedSrc , i_string ) ; map " kTaiwanTelegraph " ( KTaiwanTelegraph , i_string ) ; map " kTang " ( KTang , i_string ) ; map " kTotalStrokes " ( KTotalStrokes , i_string ) ; map " kTraditionalVariant " ( KTraditionalVariant , i_string ) ; map " kVietnamese " ( KVietnamese , i_string ) ; map " kWubi " ( KWubi , i_string ) ; map " kXHC1983 " ( KXHC1983 , i_string ) ; map " kXerox " ( KXerox , i_string ) ; map " kZVariant " ( KZVariant , i_string ) ; fun m ( n , v ) -> try match n with | ( " " , p ) -> let k , conv = Hashtbl . find h p in Pmap . add k ( conv v ) m | _ -> raise Not_found with Not_found -> Pmap . add ( Other n ) ( i_string v ) m
let attv n atts = try snd ( List . find ( fun ( en , v ) -> en = ( " " , n ) ) atts ) with | Not_found -> err_miss_att n
let rec skip_el d = let rec loop d depth = match Xmlm . input d with | ` El_start _ -> loop d ( depth + 1 ) | ` El_end -> if depth = 0 then ( ) else loop d ( depth - 1 ) | s -> loop d depth in loop d 0
let p_seq n p_atts d = let rec aux n p_atts d acc = match Xmlm . input d with | ` El_start ( n ' , atts ) when n ' = n -> if Xmlm . input d <> ` El_end then err err_exp_el_end else aux n p_atts d ( ( p_atts atts ) :: acc ) ; | ` El_start _ -> skip_el d ; aux n p_atts d acc | ` El_end -> List . rev acc | ` Data _ -> err err_data | _ -> assert false in aux n p_atts d [ ]
let p_description d = match ( Xmlm . input d ) with
let p_name_aliases d = let rec loop d depth acc = match Xmlm . peek d with | ` El_start ( n , atts ) when n = n_name_alias -> ignore ( Xmlm . input d ) ; let alias = ref " " in let atype = ref None in let p_alias_atts = function | ( " " , " alias " ) , v -> alias := v | ( " " , " type " ) , v -> atype := Some ( i_name_alias_type v ) | _ -> ( ) in List . iter p_alias_atts atts ; begin match ! atype with None -> err err_invalid_name_alias_spec | Some t -> loop d ( depth + 1 ) ( ( ! alias , t ) :: acc ) end | ` El_start ( n , atts ) -> ignore ( Xmlm . input d ) ; skip_el d ; loop d depth acc | ` El_end -> if depth = 0 then List . rev acc else ( ignore ( Xmlm . input d ) ; loop d ( depth - 1 ) acc ) | ` Data _ -> err err_data | _ -> assert false in loop d 0 [ ]
let p_cp d rep atts g_props = let cp = ref None in let cp_first = ref None in let cp_last = ref None in let add acc ( ( n , v ) as a ) = match n with | ( " " , " cp " ) -> cp := Some ( cp_of_string v ) ; acc | ( " " , " first - cp " ) -> cp_first := Some ( cp_of_string v ) ; acc | ( " " , " last - cp " ) -> cp_last := Some ( cp_of_string v ) ; acc | _ -> add_prop acc a in let props = List . fold_left add g_props atts in let props = Pmap . add Name_alias ( Name_alias_v ( p_name_aliases d ) ) props in match ! cp with | Some cp -> Cpmap . add cp props rep | None -> match ! cp_first , ! cp_last with | Some f , Some l -> let rep = ref rep in for cp = f to l do rep := Cpmap . add cp props ! rep done ; ! rep | _ -> err err_invalid_cp_spec
let p_repertoire d = let eatt t = ( " " , " uax_42_element " ) , t in let rec loop d depth rep g_atts = match Xmlm . input d with | ` El_start ( n , atts ) when n = n_reserved -> loop d ( depth + 1 ) ( p_cp d rep ( eatt " reserved " :: atts ) g_atts ) g_atts | ` El_start ( n , atts ) when n = n_noncharacter -> loop d ( depth + 1 ) ( p_cp d rep ( eatt " noncharacter " :: atts ) g_atts ) g_atts | ` El_start ( n , atts ) when n = n_surrogate -> loop d ( depth + 1 ) ( p_cp d rep ( eatt " surrogate " :: atts ) g_atts ) g_atts | ` El_start ( n , atts ) when n = n_char -> loop d ( depth + 1 ) ( p_cp d rep ( eatt " char " :: atts ) g_atts ) g_atts | ` El_start ( n , atts ) when n = n_group -> let atts = List . fold_left add_prop Pmap . empty atts in let rep = loop d 0 rep atts in loop d depth rep Pmap . empty | ` El_start ( n , atts ) -> skip_el d ; loop d depth rep g_atts | ` El_end -> if depth = 0 then rep else loop d ( depth - 1 ) rep g_atts | ` Data _ -> err err_data | _ -> assert false in loop d 0 Cpmap . empty Pmap . empty
let p_blocks d = let b_atts atts = ( cp_of_string ( attv " first - cp " atts ) , cp_of_string ( attv " last - cp " atts ) ) , attv " name " atts in p_seq n_block b_atts d
let p_named_sequences d = let ns_atts atts = attv " name " atts , cps_of_string ( attv " cps " atts ) in p_seq n_named_sequence ns_atts d
let p_normalization_corrections d = let version_of_string v = try match List . map int_of_string ( split_string v ' . ' ) with | [ v1 ; v2 ; v3 ; ] -> ( v1 , v2 , v3 ) | _ -> failwith " " with Failure _ -> err ( err_att_val v ) in let nc_atts atts = cp_of_string ( attv " cp " atts ) , cps_of_string ( attv " old " atts ) , cps_of_string ( attv " new " atts ) , version_of_string ( attv " version " atts ) in p_seq n_normalization_correction nc_atts d
let p_standardized_variants d = let when_of_string v = let w s = match s with | " isolate " -> ` Isolate | " initial " -> ` Initial | " medial " -> ` Medial | " final " -> ` Final | s -> err ( err_att_val s ) in List . map w ( split_string v ' ' ) in let sv_atts atts = cps_of_string ( attv " cps " atts ) , attv " desc " atts , when_of_string ( attv " when " atts ) in p_seq n_standardized_variant sv_atts d
let p_cjk_radicals d = let cjk_r_atts atts = attv " number " atts , cp_of_string ( attv " radical " atts ) , cp_of_string ( attv " ideograph " atts ) in p_seq n_cjk_radical cjk_r_atts d
let p_emoji_sources d = let es_atts atts = let opt_int v = if v = " " then None else Some ( cp_of_string v ) in cps_of_string ( attv " unicode " atts ) , opt_int ( attv " docomo " atts ) , opt_int ( attv " kddi " atts ) , opt_int ( attv " softbank " atts ) in p_seq n_emoji_source es_atts d
let p_ucd d = let description = ref None in let repertoire = ref None in let blocks = ref None in let named_sequences = ref None in let provisional_named_sequences = ref None in let normalization_corrections = ref None in let standardized_variants = ref None in let cjk_radicals = ref None in let emoji_sources = ref None in let set n r p d = if ! r <> None then err ( err_dup n ) else r := Some ( p d ) in while ( Xmlm . peek d <> ` El_end ) do match Xmlm . input d with | ` El_start ( n , _ ) when n = n_description -> set n description p_description d | ` El_start ( n , _ ) when n = n_repertoire -> set n repertoire p_repertoire d | ` El_start ( n , _ ) when n = n_blocks -> set n blocks p_blocks d | ` El_start ( n , _ ) when n = n_named_sequences -> set n named_sequences p_named_sequences d | ` El_start ( n , _ ) when n = n_provisional_named_sequences -> set n provisional_named_sequences p_named_sequences d | ` El_start ( n , _ ) when n = n_normalization_corrections -> set n normalization_corrections p_normalization_corrections d | ` El_start ( n , _ ) when n = n_standardized_variants -> set n standardized_variants p_standardized_variants d | ` El_start ( n , _ ) when n = n_cjk_radicals -> set n cjk_radicals p_cjk_radicals d | ` El_start ( n , _ ) when n = n_emoji_sources -> set n emoji_sources p_emoji_sources d | ` El_start ( n , _ ) -> skip_el d | ` Data _ -> err err_data | _ -> assert false done ; ignore ( Xmlm . input d ) ; if not ( Xmlm . eoi d ) then err err_wf ; let some v default = match v with Some v -> v | None -> default in { description = some ! description " " ; repertoire = some ! repertoire Cpmap . empty ; blocks = some ! blocks [ ] ; named_sequences = some ! named_sequences [ ] ; provisional_named_sequences = some ! provisional_named_sequences [ ] ; normalization_corrections = some ! normalization_corrections [ ] ; standardized_variants = some ! standardized_variants [ ] ; cjk_radicals = some ! cjk_radicals [ ] ; emoji_sources = some ! emoji_sources [ ] ; }
type src = [ ` Channel of in_channel | ` String of string ]
let decoder src = let src = match src with ` String s -> ` String ( 0 , s ) | ` Channel _ as s -> s in Xmlm . make_input ~ strip : true src
let decoded_range d = Xmlm . pos d , Xmlm . pos d
let decode d = try ignore ( Xmlm . input d ) ; begin match Xmlm . input d with | ` El_start ( n , _ ) when n = n_ucd -> ` Ok ( p_ucd d ) | ` El_start ( n , _ ) -> err ( err_exp_ucd n ) | _ -> assert false end ; with
type t = [ | ` ASCII | ` Adlam | ` Aegean_Numbers | ` Ahom | ` Alchemical | ` Alphabetic_PF | ` Anatolian_Hieroglyphs | ` Ancient_Greek_Music | ` Ancient_Greek_Numbers | ` Ancient_Symbols | ` Arabic | ` Arabic_Ext_A | ` Arabic_Ext_B | ` Arabic_Math | ` Arabic_PF_A | ` Arabic_PF_B | ` Arabic_Sup | ` Armenian | ` Arrows | ` Avestan | ` Balinese | ` Bamum | ` Bamum_Sup | ` Bassa_Vah | ` Batak | ` Bengali | ` Bhaiksuki | ` Block_Elements | ` Bopomofo | ` Bopomofo_Ext | ` Box_Drawing | ` Brahmi | ` Braille | ` Buginese | ` Buhid | ` Byzantine_Music | ` CJK | ` CJK_Compat | ` CJK_Compat_Forms | ` CJK_Compat_Ideographs | ` CJK_Compat_Ideographs_Sup | ` CJK_Ext_A | ` CJK_Ext_B | ` CJK_Ext_C | ` CJK_Ext_D | ` CJK_Ext_E | ` CJK_Ext_F | ` CJK_Ext_G | ` CJK_Radicals_Sup | ` CJK_Strokes | ` CJK_Symbols | ` Carian | ` Caucasian_Albanian | ` Chakma | ` Cham | ` Cherokee | ` Cherokee_Sup | ` Chess_Symbols | ` Chorasmian | ` Compat_Jamo | ` Control_Pictures | ` Coptic | ` Coptic_Epact_Numbers | ` Counting_Rod | ` Cuneiform | ` Cuneiform_Numbers | ` Currency_Symbols | ` Cypriot_Syllabary | ` Cypro_Minoan | ` Cyrillic | ` Cyrillic_Ext_A | ` Cyrillic_Ext_B | ` Cyrillic_Ext_C | ` Cyrillic_Sup | ` Deseret | ` Devanagari | ` Devanagari_Ext | ` Diacriticals | ` Diacriticals_Ext | ` Diacriticals_For_Symbols | ` Diacriticals_Sup | ` Dingbats | ` Dives_Akuru | ` Dogra | ` Domino | ` Duployan | ` Early_Dynastic_Cuneiform | ` Egyptian_Hieroglyph_Format_Controls | ` Egyptian_Hieroglyphs | ` Elbasan | ` Elymaic | ` Emoticons | ` Enclosed_Alphanum | ` Enclosed_Alphanum_Sup | ` Enclosed_CJK | ` Enclosed_Ideographic_Sup | ` Ethiopic | ` Ethiopic_Ext | ` Ethiopic_Ext_A | ` Ethiopic_Ext_B | ` Ethiopic_Sup | ` Geometric_Shapes | ` Geometric_Shapes_Ext | ` Georgian | ` Georgian_Ext | ` Georgian_Sup | ` Glagolitic | ` Glagolitic_Sup | ` Gothic | ` Grantha | ` Greek | ` Greek_Ext | ` Gujarati | ` Gunjala_Gondi | ` Gurmukhi | ` Half_And_Full_Forms | ` Half_Marks | ` Hangul | ` Hanifi_Rohingya | ` Hanunoo | ` Hatran | ` Hebrew | ` Hiragana | ` IDC | ` IPA_Ext | ` Ideographic_Symbols | ` Imperial_Aramaic | ` Indic_Number_Forms | ` Indic_Siyaq_Numbers | ` Inscriptional_Pahlavi | ` Inscriptional_Parthian | ` Jamo | ` Jamo_Ext_A | ` Jamo_Ext_B | ` Javanese | ` Kaithi | ` Kana_Ext_A | ` Kana_Ext_B | ` Kana_Sup | ` Kanbun | ` Kangxi | ` Kannada | ` Katakana | ` Katakana_Ext | ` Kayah_Li | ` Kharoshthi | ` Khitan_Small_Script | ` Khmer | ` Khmer_Symbols | ` Khojki | ` Khudawadi | ` Lao | ` Latin_1_Sup | ` Latin_Ext_A | ` Latin_Ext_Additional | ` Latin_Ext_B | ` Latin_Ext_C | ` Latin_Ext_D | ` Latin_Ext_E | ` Latin_Ext_F | ` Latin_Ext_G | ` Lepcha | ` Letterlike_Symbols | ` Limbu | ` Linear_A | ` Linear_B_Ideograms | ` Linear_B_Syllabary | ` Lisu | ` Lisu_Sup | ` Lycian | ` Lydian | ` Mahajani | ` Mahjong | ` Makasar | ` Malayalam | ` Mandaic | ` Manichaean | ` Marchen | ` Masaram_Gondi | ` Math_Alphanum | ` Math_Operators | ` Mayan_Numerals | ` Medefaidrin | ` Meetei_Mayek | ` Meetei_Mayek_Ext | ` Mende_Kikakui | ` Meroitic_Cursive | ` Meroitic_Hieroglyphs | ` Miao | ` Misc_Arrows | ` Misc_Math_Symbols_A | ` Misc_Math_Symbols_B | ` Misc_Pictographs | ` Misc_Symbols | ` Misc_Technical | ` Modi | ` Modifier_Letters | ` Modifier_Tone_Letters | ` Mongolian | ` Mongolian_Sup | ` Mro | ` Multani | ` Music | ` Myanmar | ` Myanmar_Ext_A | ` Myanmar_Ext_B | ` NB | ` NKo | ` Nabataean | ` Nandinagari | ` New_Tai_Lue | ` Newa | ` Number_Forms | ` Nushu | ` Nyiakeng_Puachue_Hmong | ` OCR | ` Ogham | ` Ol_Chiki | ` Old_Hungarian | ` Old_Italic | ` Old_North_Arabian | ` Old_Permic | ` Old_Persian | ` Old_Sogdian | ` Old_South_Arabian | ` Old_Turkic | ` Old_Uyghur | ` Oriya | ` Ornamental_Dingbats | ` Osage | ` Osmanya | ` Ottoman_Siyaq_Numbers | ` PUA | ` Pahawh_Hmong | ` Palmyrene | ` Pau_Cin_Hau | ` Phags_Pa | ` Phaistos | ` Phoenician | ` Phonetic_Ext | ` Phonetic_Ext_Sup | ` Playing_Cards | ` Psalter_Pahlavi | ` Punctuation | ` Rejang | ` Rumi | ` Runic | ` Samaritan | ` Saurashtra | ` Sharada | ` Shavian | ` Shorthand_Format_Controls | ` Siddham | ` Sinhala | ` Sinhala_Archaic_Numbers | ` Small_Forms | ` Small_Kana_Ext | ` Sogdian | ` Sora_Sompeng | ` Soyombo | ` Specials | ` Sundanese | ` Sundanese_Sup | ` Sup_Arrows_A | ` Sup_Arrows_B | ` Sup_Arrows_C | ` Sup_Math_Operators | ` Sup_PUA_A | ` Sup_PUA_B | ` Sup_Punctuation | ` Sup_Symbols_And_Pictographs | ` Super_And_Sub | ` Sutton_SignWriting | ` Syloti_Nagri | ` Symbols_And_Pictographs_Ext_A | ` Symbols_For_Legacy_Computing | ` Syriac | ` Syriac_Sup | ` Tagalog | ` Tagbanwa | ` Tags | ` Tai_Le | ` Tai_Tham | ` Tai_Viet | ` Tai_Xuan_Jing | ` Takri | ` Tamil | ` Tamil_Sup | ` Tangsa | ` Tangut | ` Tangut_Components | ` Tangut_Sup | ` Telugu | ` Thaana | ` Thai | ` Tibetan | ` Tifinagh | ` Tirhuta | ` Toto | ` Transport_And_Map | ` UCAS | ` UCAS_Ext | ` UCAS_Ext_A | ` Ugaritic | ` VS | ` VS_Sup | ` Vai | ` Vedic_Ext | ` Vertical_Forms | ` Vithkuqi | ` Wancho | ` Warang_Citi | ` Yezidi | ` Yi_Radicals | ` Yi_Syllables | ` Yijing | ` Zanabazar_Square | ` Znamenny_Music ]
let pp ppf b = Format . fprintf ppf " % s " begin match b with | ` ASCII -> " ASCII " | ` Adlam -> " Adlam " | ` Aegean_Numbers -> " Aegean_Numbers " | ` Ahom -> " Ahom " | ` Alchemical -> " Alchemical " | ` Alphabetic_PF -> " Alphabetic_PF " | ` Anatolian_Hieroglyphs -> " Anatolian_Hieroglyphs " | ` Ancient_Greek_Music -> " Ancient_Greek_Music " | ` Ancient_Greek_Numbers -> " Ancient_Greek_Numbers " | ` Ancient_Symbols -> " Ancient_Symbols " | ` Arabic -> " Arabic " | ` Arabic_Ext_A -> " Arabic_Ext_A " | ` Arabic_Ext_B -> " Arabic_Ext_B " | ` Arabic_Math -> " Arabic_Math " | ` Arabic_PF_A -> " Arabic_PF_A " | ` Arabic_PF_B -> " Arabic_PF_B " | ` Arabic_Sup -> " Arabic_Sup " | ` Armenian -> " Armenian " | ` Arrows -> " Arrows " | ` Avestan -> " Avestan " | ` Balinese -> " Balinese " | ` Bamum -> " Bamum " | ` Bamum_Sup -> " Bamum_Sup " | ` Bassa_Vah -> " Bassa_Vah " | ` Batak -> " Batak " | ` Bengali -> " Bengali " | ` Bhaiksuki -> " Bhaiksuki " | ` Block_Elements -> " Block_Elements " | ` Bopomofo -> " Bopomofo " | ` Bopomofo_Ext -> " Bopomofo_Ext " | ` Box_Drawing -> " Box_Drawing " | ` Brahmi -> " Brahmi " | ` Braille -> " Braille " | ` Buginese -> " Buginese " | ` Buhid -> " Buhid " | ` Byzantine_Music -> " Byzantine_Music " | ` CJK -> " CJK " | ` CJK_Compat -> " CJK_Compat " | ` CJK_Compat_Forms -> " CJK_Compat_Forms " | ` CJK_Compat_Ideographs -> " CJK_Compat_Ideographs " | ` CJK_Compat_Ideographs_Sup -> " CJK_Compat_Ideographs_Sup " | ` CJK_Ext_A -> " CJK_Ext_A " | ` CJK_Ext_B -> " CJK_Ext_B " | ` CJK_Ext_C -> " CJK_Ext_C " | ` CJK_Ext_D -> " CJK_Ext_D " | ` CJK_Ext_E -> " CJK_Ext_E " | ` CJK_Ext_F -> " CJK_Ext_F " | ` CJK_Ext_G -> " CJK_Ext_G " | ` CJK_Radicals_Sup -> " CJK_Radicals_Sup " | ` CJK_Strokes -> " CJK_Strokes " | ` CJK_Symbols -> " CJK_Symbols " | ` Carian -> " Carian " | ` Caucasian_Albanian -> " Caucasian_Albanian " | ` Chakma -> " Chakma " | ` Cham -> " Cham " | ` Cherokee -> " Cherokee " | ` Cherokee_Sup -> " Cherokee_Sup " | ` Chess_Symbols -> " Chess_Symbols " | ` Chorasmian -> " Chorasmian " | ` Compat_Jamo -> " Compat_Jamo " | ` Control_Pictures -> " Control_Pictures " | ` Coptic -> " Coptic " | ` Coptic_Epact_Numbers -> " Coptic_Epact_Numbers " | ` Counting_Rod -> " Counting_Rod " | ` Cuneiform -> " Cuneiform " | ` Cuneiform_Numbers -> " Cuneiform_Numbers " | ` Currency_Symbols -> " Currency_Symbols " | ` Cypriot_Syllabary -> " Cypriot_Syllabary " | ` Cypro_Minoan -> " Cypro_Minoan " | ` Cyrillic -> " Cyrillic " | ` Cyrillic_Ext_A -> " Cyrillic_Ext_A " | ` Cyrillic_Ext_B -> " Cyrillic_Ext_B " | ` Cyrillic_Ext_C -> " Cyrillic_Ext_C " | ` Cyrillic_Sup -> " Cyrillic_Sup " | ` Deseret -> " Deseret " | ` Devanagari -> " Devanagari " | ` Devanagari_Ext -> " Devanagari_Ext " | ` Diacriticals -> " Diacriticals " | ` Diacriticals_Ext -> " Diacriticals_Ext " | ` Diacriticals_For_Symbols -> " Diacriticals_For_Symbols " | ` Diacriticals_Sup -> " Diacriticals_Sup " | ` Dingbats -> " Dingbats " | ` Dives_Akuru -> " Dives_Akuru " | ` Dogra -> " Dogra " | ` Domino -> " Domino " | ` Duployan -> " Duployan " | ` Early_Dynastic_Cuneiform -> " Early_Dynastic_Cuneiform " | ` Egyptian_Hieroglyph_Format_Controls -> " Egyptian_Hieroglyph_Format_Controls " | ` Egyptian_Hieroglyphs -> " Egyptian_Hieroglyphs " | ` Elbasan -> " Elbasan " | ` Elymaic -> " Elymaic " | ` Emoticons -> " Emoticons " | ` Enclosed_Alphanum -> " Enclosed_Alphanum " | ` Enclosed_Alphanum_Sup -> " Enclosed_Alphanum_Sup " | ` Enclosed_CJK -> " Enclosed_CJK " | ` Enclosed_Ideographic_Sup -> " Enclosed_Ideographic_Sup " | ` Ethiopic -> " Ethiopic " | ` Ethiopic_Ext -> " Ethiopic_Ext " | ` Ethiopic_Ext_A -> " Ethiopic_Ext_A " | ` Ethiopic_Ext_B -> " Ethiopic_Ext_B " | ` Ethiopic_Sup -> " Ethiopic_Sup " | ` Geometric_Shapes -> " Geometric_Shapes " | ` Geometric_Shapes_Ext -> " Geometric_Shapes_Ext " | ` Georgian -> " Georgian " | ` Georgian_Ext -> " Georgian_Ext " | ` Georgian_Sup -> " Georgian_Sup " | ` Glagolitic -> " Glagolitic " | ` Glagolitic_Sup -> " Glagolitic_Sup " | ` Gothic -> " Gothic " | ` Grantha -> " Grantha " | ` Greek -> " Greek " | ` Greek_Ext -> " Greek_Ext " | ` Gujarati -> " Gujarati " | ` Gunjala_Gondi -> " Gunjala_Gondi " | ` Gurmukhi -> " Gurmukhi " | ` Half_And_Full_Forms -> " Half_And_Full_Forms " | ` Half_Marks -> " Half_Marks " | ` Hangul -> " Hangul " | ` Hanifi_Rohingya -> " Hanifi_Rohingya " | ` Hanunoo -> " Hanunoo " | ` Hatran -> " Hatran " | ` Hebrew -> " Hebrew " | ` High_PU_Surrogates -> " High_PU_Surrogates " | ` High_Surrogates -> " High_Surrogates " | ` Hiragana -> " Hiragana " | ` IDC -> " IDC " | ` IPA_Ext -> " IPA_Ext " | ` Ideographic_Symbols -> " Ideographic_Symbols " | ` Imperial_Aramaic -> " Imperial_Aramaic " | ` Indic_Number_Forms -> " Indic_Number_Forms " | ` Indic_Siyaq_Numbers -> " Indic_Siyaq_Numbers " | ` Inscriptional_Pahlavi -> " Inscriptional_Pahlavi " | ` Inscriptional_Parthian -> " Inscriptional_Parthian " | ` Jamo -> " Jamo " | ` Jamo_Ext_A -> " Jamo_Ext_A " | ` Jamo_Ext_B -> " Jamo_Ext_B " | ` Javanese -> " Javanese " | ` Kaithi -> " Kaithi " | ` Kana_Ext_A -> " Kana_Ext_A " | ` Kana_Ext_B -> " Kana_Ext_B " | ` Kana_Sup -> " Kana_Sup " | ` Kanbun -> " Kanbun " | ` Kangxi -> " Kangxi " | ` Kannada -> " Kannada " | ` Katakana -> " Katakana " | ` Katakana_Ext -> " Katakana_Ext " | ` Kayah_Li -> " Kayah_Li " | ` Kharoshthi -> " Kharoshthi " | ` Khitan_Small_Script -> " Khitan_Small_Script " | ` Khmer -> " Khmer " | ` Khmer_Symbols -> " Khmer_Symbols " | ` Khojki -> " Khojki " | ` Khudawadi -> " Khudawadi " | ` Lao -> " Lao " | ` Latin_1_Sup -> " Latin_1_Sup " | ` Latin_Ext_A -> " Latin_Ext_A " | ` Latin_Ext_Additional -> " Latin_Ext_Additional " | ` Latin_Ext_B -> " Latin_Ext_B " | ` Latin_Ext_C -> " Latin_Ext_C " | ` Latin_Ext_D -> " Latin_Ext_D " | ` Latin_Ext_E -> " Latin_Ext_E " | ` Latin_Ext_F -> " Latin_Ext_F " | ` Latin_Ext_G -> " Latin_Ext_G " | ` Lepcha -> " Lepcha " | ` Letterlike_Symbols -> " Letterlike_Symbols " | ` Limbu -> " Limbu " | ` Linear_A -> " Linear_A " | ` Linear_B_Ideograms -> " Linear_B_Ideograms " | ` Linear_B_Syllabary -> " Linear_B_Syllabary " | ` Lisu -> " Lisu " | ` Lisu_Sup -> " Lisu_Sup " | ` Low_Surrogates -> " Low_Surrogates " | ` Lycian -> " Lycian " | ` Lydian -> " Lydian " | ` Mahajani -> " Mahajani " | ` Mahjong -> " Mahjong " | ` Makasar -> " Makasar " | ` Malayalam -> " Malayalam " | ` Mandaic -> " Mandaic " | ` Manichaean -> " Manichaean " | ` Marchen -> " Marchen " | ` Masaram_Gondi -> " Masaram_Gondi " | ` Math_Alphanum -> " Math_Alphanum " | ` Math_Operators -> " Math_Operators " | ` Mayan_Numerals -> " Mayan_Numerals " | ` Medefaidrin -> " Medefaidrin " | ` Meetei_Mayek -> " Meetei_Mayek " | ` Meetei_Mayek_Ext -> " Meetei_Mayek_Ext " | ` Mende_Kikakui -> " Mende_Kikakui " | ` Meroitic_Cursive -> " Meroitic_Cursive " | ` Meroitic_Hieroglyphs -> " Meroitic_Hieroglyphs " | ` Miao -> " Miao " | ` Misc_Arrows -> " Misc_Arrows " | ` Misc_Math_Symbols_A -> " Misc_Math_Symbols_A " | ` Misc_Math_Symbols_B -> " Misc_Math_Symbols_B " | ` Misc_Pictographs -> " Misc_Pictographs " | ` Misc_Symbols -> " Misc_Symbols " | ` Misc_Technical -> " Misc_Technical " | ` Modi -> " Modi " | ` Modifier_Letters -> " Modifier_Letters " | ` Modifier_Tone_Letters -> " Modifier_Tone_Letters " | ` Mongolian -> " Mongolian " | ` Mongolian_Sup -> " Mongolian_Sup " | ` Mro -> " Mro " | ` Multani -> " Multani " | ` Music -> " Music " | ` Myanmar -> " Myanmar " | ` Myanmar_Ext_A -> " Myanmar_Ext_A " | ` Myanmar_Ext_B -> " Myanmar_Ext_B " | ` NB -> " NB " | ` NKo -> " NKo " | ` Nabataean -> " Nabataean " | ` Nandinagari -> " Nandinagari " | ` New_Tai_Lue -> " New_Tai_Lue " | ` Newa -> " Newa " | ` Number_Forms -> " Number_Forms " | ` Nushu -> " Nushu " | ` Nyiakeng_Puachue_Hmong -> " Nyiakeng_Puachue_Hmong " | ` OCR -> " OCR " | ` Ogham -> " Ogham " | ` Ol_Chiki -> " Ol_Chiki " | ` Old_Hungarian -> " Old_Hungarian " | ` Old_Italic -> " Old_Italic " | ` Old_North_Arabian -> " Old_North_Arabian " | ` Old_Permic -> " Old_Permic " | ` Old_Persian -> " Old_Persian " | ` Old_Sogdian -> " Old_Sogdian " | ` Old_South_Arabian -> " Old_South_Arabian " | ` Old_Turkic -> " Old_Turkic " | ` Old_Uyghur -> " Old_Uyghur " | ` Oriya -> " Oriya " | ` Ornamental_Dingbats -> " Ornamental_Dingbats " | ` Osage -> " Osage " | ` Osmanya -> " Osmanya " | ` Ottoman_Siyaq_Numbers -> " Ottoman_Siyaq_Numbers " | ` PUA -> " PUA " | ` Pahawh_Hmong -> " Pahawh_Hmong " | ` Palmyrene -> " Palmyrene " | ` Pau_Cin_Hau -> " Pau_Cin_Hau " | ` Phags_Pa -> " Phags_Pa " | ` Phaistos -> " Phaistos " | ` Phoenician -> " Phoenician " | ` Phonetic_Ext -> " Phonetic_Ext " | ` Phonetic_Ext_Sup -> " Phonetic_Ext_Sup " | ` Playing_Cards -> " Playing_Cards " | ` Psalter_Pahlavi -> " Psalter_Pahlavi " | ` Punctuation -> " Punctuation " | ` Rejang -> " Rejang " | ` Rumi -> " Rumi " | ` Runic -> " Runic " | ` Samaritan -> " Samaritan " | ` Saurashtra -> " Saurashtra " | ` Sharada -> " Sharada " | ` Shavian -> " Shavian " | ` Shorthand_Format_Controls -> " Shorthand_Format_Controls " | ` Siddham -> " Siddham " | ` Sinhala -> " Sinhala " | ` Sinhala_Archaic_Numbers -> " Sinhala_Archaic_Numbers " | ` Small_Forms -> " Small_Forms " | ` Small_Kana_Ext -> " Small_Kana_Ext " | ` Sogdian -> " Sogdian " | ` Sora_Sompeng -> " Sora_Sompeng " | ` Soyombo -> " Soyombo " | ` Specials -> " Specials " | ` Sundanese -> " Sundanese " | ` Sundanese_Sup -> " Sundanese_Sup " | ` Sup_Arrows_A -> " Sup_Arrows_A " | ` Sup_Arrows_B -> " Sup_Arrows_B " | ` Sup_Arrows_C -> " Sup_Arrows_C " | ` Sup_Math_Operators -> " Sup_Math_Operators " | ` Sup_PUA_A -> " Sup_PUA_A " | ` Sup_PUA_B -> " Sup_PUA_B " | ` Sup_Punctuation -> " Sup_Punctuation " | ` Sup_Symbols_And_Pictographs -> " Sup_Symbols_And_Pictographs " | ` Symbols_For_Legacy_Computing -> " Symbols_For_Legacy_Computing " | ` Super_And_Sub -> " Super_And_Sub " | ` Sutton_SignWriting -> " Sutton_SignWriting " | ` Syloti_Nagri -> " Syloti_Nagri " | ` Symbols_And_Pictographs_Ext_A -> " Symbols_And_Pictographs_Ext_A " | ` Syriac -> " Syriac " | ` Syriac_Sup -> " Syriac_Sup " | ` Tagalog -> " Tagalog " | ` Tagbanwa -> " Tagbanwa " | ` Tags -> " Tags " | ` Tai_Le -> " Tai_Le " | ` Tai_Tham -> " Tai_Tham " | ` Tai_Viet -> " Tai_Viet " | ` Tai_Xuan_Jing -> " Tai_Xuan_Jing " | ` Takri -> " Takri " | ` Tamil -> " Tamil " | ` Tamil_Sup -> " Tamil_Sup " | ` Tangsa -> " Tangsa " | ` Tangut -> " Tangut " | ` Tangut_Components -> " Tangut_Components " | ` Tangut_Sup -> " Tangut_Sup " | ` Telugu -> " Telugu " | ` Thaana -> " Thaana " | ` Thai -> " Thai " | ` Tibetan -> " Tibetan " | ` Tifinagh -> " Tifinagh " | ` Tirhuta -> " Tirhuta " | ` Toto -> " Toto " | ` Transport_And_Map -> " Transport_And_Map " | ` UCAS -> " UCAS " | ` UCAS_Ext -> " UCAS_Ext " | ` UCAS_Ext_A -> " UCAS_Ext_A " | ` Ugaritic -> " Ugaritic " | ` VS -> " VS " | ` VS_Sup -> " VS_Sup " | ` Vai -> " Vai " | ` Vedic_Ext -> " Vedic_Ext " | ` Vertical_Forms -> " Vertical_Forms " | ` Vithkuqi -> " Vithkuqi " | ` Wancho -> " Wancho " | ` Warang_Citi -> " Warang_Citi " | ` Yezidi -> " Yezidi " | ` Yi_Radicals -> " Yi_Radicals " | ` Yi_Syllables -> " Yi_Syllables " | ` Yijing -> " Yijing " | ` Zanabazar_Square -> " Zanabazar_Square " | ` Znamenny_Music -> " Znamenny_Music " end
module Low = struct let line u = Uucp_tmapbyte . get Uucp_break_data . line_break_map ( Uchar . to_int u ) let line_max = line_max let line_of_int = line_of_byte let grapheme_cluster u = Uucp_tmapbyte . get Uucp_break_data . grapheme_cluster_break_map ( Uchar . to_int u ) let grapheme_cluster_max = grapheme_cluster_max let grapheme_cluster_of_int = grapheme_cluster_of_byte let word u = Uucp_tmapbyte . get Uucp_break_data . word_break_map ( Uchar . to_int u ) let word_max = word_max let word_of_int = word_of_byte let sentence u = Uucp_tmapbyte . get Uucp_break_data . sentence_break_map ( Uchar . to_int u ) let sentence_max = sentence_max let sentence_of_int = sentence_of_byte end
let line u = Array . unsafe_get Low . line_of_int ( Low . line u )
let grapheme_cluster u = Array . unsafe_get Low . grapheme_cluster_of_int ( Low . grapheme_cluster u )
let word u = Array . unsafe_get Low . word_of_int ( Low . word u )
let sentence u = Array . unsafe_get Low . sentence_of_int ( Low . sentence u )
let east_asian_width u = Uucp_rmap . get Uucp_break_data . east_asian_width_map ( Uchar . to_int u )
let tty_width_hint = let gc i = Uucp_gc . general_category ( Uchar . unsafe_of_int i ) in let eaw i = east_asian_width ( Uchar . unsafe_of_int i ) in fun u -> match Uchar . to_int u with | 0 -> 0 | u when u <= 0x001F || 0x007F <= u && u <= 0x009F -> - 1 | u when u <= 0x02FF -> 1 | u when ( let c = gc u in c = ` Mn || c = ` Me || c = ` Cf ) -> 0 | u when ( let w = eaw u in w = ` W || w = ` F ) -> 2 | _ -> 1
type line = [ ` AI | ` AL | ` B2 | ` BA | ` BB | ` BK | ` CB | ` CJ | ` CL | ` CM | ` CP | ` CR | ` EX | ` EB | ` EM | ` GL | ` H2 | ` H3 | ` HL | ` HY | ` ID | ` IN | ` IS | ` JL | ` JT | ` JV | ` LF | ` NL | ` NS | ` NU | ` OP | ` PO | ` PR | ` QU | ` RI | ` SA | ` SG | ` SP | ` SY | ` WJ | ` XX | ` ZW | ` ZWJ ]
let line_of_byte : line array = [ | ` AI ; ` AL ; ` B2 ; ` BA ; ` BB ; ` BK ; ` CB ; ` CJ ; ` CL ; ` CM ; ` CP ; ` CR ; ` EX ; ` EB ; ` EM ; ` GL ; ` H2 ; ` H3 ; ` HL ; ` HY ; ` ID ; ` IN ; ` IS ; ` JL ; ` JT ; ` JV ; ` LF ; ` NL ; ` NS ; ` NU ; ` OP ; ` PO ; ` PR ; ` QU ; ` RI ; ` SA ; ` SG ; ` SP ; ` SY ; ` WJ ; ` XX ; ` ZW ; ` ZWJ ] |
let line_max = Array . length line_of_byte - 1
let pp_line ppf v = Format . fprintf ppf " % s " begin match v with | ` AI -> " AI " | ` AL -> " AL " | ` B2 -> " B2 " | ` BA -> " BA " | ` BB -> " BB " | ` BK -> " BK " | ` CB -> " CB " | ` CJ -> " CJ " | ` CL -> " CL " | ` CM -> " CM " | ` CP -> " CP " | ` CR -> " CR " | ` EX -> " EX " | ` EB -> " EB " | ` EM -> " EM " | ` GL -> " GL " | ` H2 -> " H2 " | ` H3 -> " H3 " | ` HL -> " HL " | ` HY -> " HY " | ` ID -> " ID " | ` IN -> " IN " | ` IS -> " IS " | ` JL -> " JL " | ` JT -> " JT " | ` JV -> " JV " | ` LF -> " LF " | ` NL -> " NL " | ` NS -> " NS " | ` NU -> " NU " | ` OP -> " OP " | ` PO -> " PO " | ` PR -> " PR " | ` QU -> " QU " | ` RI -> " RI " | ` SA -> " SA " | ` SG -> " SG " | ` SP -> " SP " | ` SY -> " SY " | ` WJ -> " WJ " | ` XX -> " XX " | ` ZW -> " ZW " | ` ZWJ -> " ZWJ " end
type grapheme_cluster = [ ` CN | ` CR | ` EX | ` EB | ` EBG | ` EM | ` GAZ | ` L | ` LF | ` LV | ` LVT | ` PP | ` RI | ` SM | ` T | ` V | ` XX | ` ZWJ ]
let grapheme_cluster_of_byte : grapheme_cluster array = [ | ` CN ; ` CR ; ` EX ; ` EB ; ` EBG ; ` EM ; ` GAZ ; ` L ; ` LF ; ` LV ; ` LVT ; ` PP ; ` RI ; ` SM ; ` T ; ` V ; ` XX ; ` ZWJ ] |
let grapheme_cluster_max = Array . length grapheme_cluster_of_byte - 1
let pp_grapheme_cluster ppf v = Format . fprintf ppf " % s " begin match v with | ` CN -> " CN " | ` CR -> " CR " | ` EX -> " EX " | ` EB -> " EB " | ` EBG -> " EBG " | ` EM -> " EM " | ` GAZ -> " GAZ " | ` L -> " L " | ` LF -> " LF " | ` LV -> " LV " | ` LVT -> " LVT " | ` PP -> " PP " | ` RI -> " RI " | ` SM -> " SM " | ` T -> " T " | ` V -> " V " | ` XX -> " XX " | ` ZWJ -> " ZWJ " end
type word = [ ` CR | ` DQ | ` EX | ` EB | ` EBG | ` EM | ` Extend | ` FO | ` GAZ | ` HL | ` KA | ` LE | ` LF | ` MB | ` ML | ` MN | ` NL | ` NU | ` RI | ` SQ | ` WSegSpace | ` XX | ` ZWJ ]
let word_of_byte : word array = [ | ` CR ; ` DQ ; ` EX ; ` EB ; ` EBG ; ` EM ; ` Extend ; ` FO ; ` GAZ ; ` HL ; ` KA ; ` LE ; ` LF ; ` MB ; ` ML ; ` MN ; ` NL ; ` NU ; ` RI ; ` SQ ; ` WSegSpace ; ` XX ; ` ZWJ ] |
let word_max = Array . length word_of_byte - 1
let pp_word ppf v = Format . fprintf ppf " % s " begin match v with | ` CR -> " CR " | ` DQ -> " DQ " | ` EX -> " EX " | ` EB -> " EB " | ` EBG -> " EBG " | ` EM -> " EM " | ` Extend -> " Extend " | ` FO -> " FO " | ` GAZ -> " GAZ " | ` HL -> " HL " | ` KA -> " KA " | ` LE -> " LE " | ` LF -> " LF " | ` MB -> " MB " | ` ML -> " ML " | ` MN -> " MN " | ` NL -> " NL " | ` NU -> " NU " | ` RI -> " RI " | ` SQ -> " SQ " | ` WSegSpace -> " WSegSpace " | ` XX -> " XX " | ` ZWJ -> " ZWJ " end
type sentence = [ ` AT | ` CL | ` CR | ` EX | ` FO | ` LE | ` LF | ` LO | ` NU | ` SC | ` SE | ` SP | ` ST | ` UP | ` XX ]
let sentence_of_byte : sentence array = [ | ` AT ; ` CL ; ` CR ; ` EX ; ` FO ; ` LE ; ` LF ; ` LO ; ` NU ; ` SC ; ` SE ; ` SP ; ` ST ; ` UP ; ` XX ] |
let sentence_max = Array . length sentence_of_byte - 1
let pp_sentence ppf v = Format . fprintf ppf " % s " begin match v with | ` AT -> " AT " | ` CL -> " CL " | ` CR -> " CR " | ` EX -> " EX " | ` FO -> " FO " | ` LE -> " LE " | ` LF -> " LF " | ` LO -> " LO " | ` NU -> " NU " | ` SC -> " SC " | ` SE -> " SE " | ` SP -> " SP " | ` ST -> " ST " | ` UP -> " UP " | ` XX -> " XX " end
type east_asian_width = [ ` A | ` F | ` H | ` N | ` Na | ` W ]
let pp_east_asian_width ppf v = Format . pp_print_string ppf begin match v with end
type ' a tree = | Empty | C of int * ' a | Cn of ' a tree * ' a tree * int * ' a
type ' a t = { default : ' a ; tree : ' a tree }
let get m cp = let rec loop cp = function | Cn ( l , r , i , v ) -> if cp < i then loop cp l else if cp > i then loop cp r else v | C ( i , v ) -> if cp = i then v else m . default | Empty -> m . default in loop cp m . tree
let of_sorted_list default l = let rec loop len l = if len = 1 then match l with | ` C ( i , v ) :: r -> C ( i , v ) , r | _ -> assert false else let len_ll = len / 2 in let len_rl = len - len_ll in let ltree , rlist = loop len_ll l in match rlist with | [ ] -> ltree , [ ] | ` C ( i , v ) :: r -> if len_rl = 1 then Cn ( ltree , Empty , i , v ) , r else let rtree , rlist = loop ( len_rl - 1 ) r in Cn ( ltree , rtree , i , v ) , rlist in let keep acc ( ` C ( _ , v ) as p ) = if v <> default then p :: acc else acc in let l = List . rev ( List . fold_left keep [ ] l ) in let len = List . length l in let tree = if len = 0 then Empty else fst ( loop len l ) in { default ; tree }
let height m = let rec loop = function | Empty -> 0 | C _ -> 1 | Cn ( l , r , _ , _ ) -> 1 + max ( loop l ) ( loop r ) in loop m . tree
let word_size v_size m = let rec loop = function | Empty -> 0 | C ( _ , v ) -> 3 + v_size v | Cn ( l , r , _ , v ) -> 5 + loop l + loop r + v_size v in loop m . tree
let rec dump pp_v ppf m = let open Uucp_fmt in let rec dump_tree ppf = function | Cn ( l , r , i , v ) -> pf ppf " [ @< 4 > Cn ( % a , , @% a , , @ 0x % 04X , , @% a ) ] " @ dump_tree l dump_tree r i pp_v v | C ( i , v ) -> pf ppf " [ @< 3 > C ( 0x % 04X , , @% a ) ] " @ i pp_v v | Empty -> pf ppf " Empty " in record [ " default " , pp_v ; " tree " , dump_tree ] ppf m . default m . tree