void GenerateSimpleCaseMappingListC (UcdCharacterProperty [] ucd, bool upper, bool small) { int nTable = 0; foreach (var cpr in catalog.SimpleCases) { if (small && cpr.Start > 0xFFFF) break; if (!small && cpr.Start < 0x10000) continue; w.WriteLine ("static const {0} simple_{1}_case_mapping_{2}_table{3} [] = {{", small ? "guint16" : "guint32", upper ? "upper" : "lower", small ? "lowarea" : "higharea", nTable); w.WriteLine ("\t/* ==== {0:X}-{1:X} ==== */", cpr.Start, cpr.End); w.Write ("\t"); int cp = cpr.Start; foreach (var ucp in ucd) { if (ucp.Codepoint >= cpr.End) break; if (ucp.Codepoint < cp) continue; while (cp < ucp.Codepoint) { w.Write ("0,"); if (++cp % 16 == 0) w.WriteLine (); } int v = upper ? ucp.SimpleUppercaseMapping : ucp.SimpleLowercaseMapping; if (v != 0) w.Write ("0x{0:X},", v); else w.Write ("0,"); if (++cp % 16 == 0) { w.WriteLine (); w.Write ("\t"); } if (cp >= cpr.End) break; } w.WriteLine ("0};"); nTable++; } w.WriteLine ("static const {0} *simple_{1}_case_mapping_{2} [] = {{", small ? "guint16" : "guint32", upper ? "upper" : "lower", small ? "lowarea" : "higharea"); for (int i = 0; i < nTable; i++) { if (i > 0) w.WriteLine (","); w.Write ("\tstatic const guint8 simple_{0}_case_mapping_{1}_table{2}", upper ? "upper" : "lower", small ? "lowarea" : "higharea", i); } w.WriteLine ("};"); w.WriteLine (); }
public void GenerateSimpleTitlecaseMappingListC (UcdCharacterProperty [] ucd) { w.WriteLine ("static const SimpleTitlecaseMapping simple_titlecase_mapping [] = {"); int count = 0; foreach (var ucp in ucd) { if (ucp.SimpleUppercaseMapping == ucp.SimpleTitlecaseMapping) continue; if (count > 0) w.WriteLine (','); w.Write ("\t{{0x{0:X06}, 0x{1:X06}, 0x{2:X06}}}", ucp.Codepoint, ucp.SimpleUppercaseMapping, ucp.SimpleTitlecaseMapping); count++; } w.WriteLine (); w.WriteLine ("};"); w.WriteLine ("static const guint8 simple_titlecase_mapping_count = {0};", count); }
public void GenerateSimpleCaseMappingListC (UcdCharacterProperty [] ucd) { GenerateCodePointRanges ("simple_case_map_ranges", catalog.SimpleCases); GenerateSimpleCaseMappingListC (ucd, true, true); GenerateSimpleCaseMappingListC (ucd, true, false); GenerateSimpleCaseMappingListC (ucd, false, true); GenerateSimpleCaseMappingListC (ucd, false, false); }
public void GenerateUnicodeCategoryListC (UcdCharacterProperty [] ucd) { w.WriteLine ("/* ======== Unicode Categories ======== */"); GenerateCodePointRanges ("unicode_category_ranges", catalog.CategoryRanges); int table = 0; foreach (var cpr in catalog.CategoryRanges) { w.WriteLine ("const GUnicodeType unicode_category_table{0} [] = {{", table); w.WriteLine ("\t/* ==== {0:X}-{1:X} ==== */", cpr.Start, cpr.End); w.Write ("\t"); int cp = cpr.Start; foreach (var ucp in ucd) { if (ucp.Codepoint >= cpr.End) break; if (ucp.Codepoint < cp) continue; while (cp < ucp.Codepoint) { w.Write ("0,"); if (++cp % 16 == 0) // w.Write ("\n/* ==== {0:X} ==== */\n\t", cp); w.Write ("\n\t", cp); } w.Write ((int) ToGUnicodeCategory (ucp.Category)); w.Write (','); if (++cp % 16 == 0) // w.Write ("\n/* ==== {0:X} ==== */\n\t", cp); w.Write ("\n\t", cp); if (cp >= cpr.End) break; } w.WriteLine ("0};"); table++; } w.WriteLine ("static const GUnicodeType *unicode_category [{0}] = {{", catalog.CategoryRanges.Length); for (int i = 0, end = catalog.CategoryRanges.Length; i < end; i++) w.WriteLine ("\tunicode_category_table{0}{1}", i, i + 1 < end ? "," : String.Empty); w.WriteLine ("};"); }