static LangMatrixRow fromCldr(Locale loc, string path) { var finds = loc.FindOrDefault(path); if (finds == null) { return(null); } var res = new Dictionary <string, string>(); foreach (var kv in finds.SelectChildren(XPathNodeType.Element).OfType <XPathNavigator>()) { var key = kv.SelectSingleNode("./@type").Value; if (res.ContainsKey(key)) { continue; } var value = kv.SelectSingleNode("./text()").Value; if (UnicodeBlocks.checkBlockNames(value, loc.Id.Script) != null) { continue; } res[key] = value; } return(new LangMatrixRow { lang = loc.Id.ToString(), row = res.Values.ToArray(), columnNames = res.Keys.ToArray(), }); }
public void checkTexts(Dictionary <string, Dictionary <string, string> > protocol) { var locId = LocaleIdentifier.Parse(lang); var wrongs = UnicodeBlocks.checkBlockNames(row, locId.Script); if (wrongs == null) { return; } protocol[lang] = wrongs; }
static string[] getNetRowData(CultureInfo lc, string Language, string Region, out LocaleIdentifier locId) { var values = new string[count]; var fmt = lc.DateTimeFormat; fmt.MonthNames.Take(12).ToArray(values, monthsIdx); fmt.MonthGenitiveNames.Take(12).ToArray(values, smonthsIdx); fmt.DayNames.Take(7).ToArray(values, daysIdx); var script = UnicodeBlocks.getBlockNames(values).Select(kv => kv.Key).Single(); locId = LocaleIdentifier.Parse(string.Format("{0}-{1}-{2}", Language, script, Region)); return(values); }
// check diff among own and .net letter test public static void dumpNetUncLettersDiff() { var l = UnicodeBlocks.sorted; // all letters in .NET and UNC var netLetters = Enumerable.Range(0, 0xffff).Where(i => char.IsLetter(Convert.ToChar(i))).ToArray(); var uncLetters = Enumerable.Range(0, 0xffff).Where(i => UnicodeBlocks.isLetter(Convert.ToChar(i))).ToArray(); //var uncLetters = new List<int>(); //foreach (var r in l) uncLetters.AddRange(Enumerable.Range(r.Key.start, r.Key.end - r.Key.start + 1)); //var uncLetters = uncCodes.Select(i => Convert.ToChar(i)).ToArray(); // .NET x UNC diff var notNet = uncLetters.Except(netLetters).OrderBy(ch => ch).ToArray(); // 116 missing var notUnc = netLetters.Except(uncLetters).OrderBy(ch => ch).ToArray(); // 2 missing }
/// <summary> /// Builds a NFA from a unicode block /// </summary> /// <param name="node">An AST node representing a NFA</param> /// <returns>The equivalent NFA</returns> private NFA BuildNFAFromUnicodeBlock(ASTNode node) { // extract the value string value = node.Value.Substring(3, node.Value.Length - 4); UnicodeBlock block = UnicodeBlocks.GetBlock(value); if (block == null) { OnError(node.Position, "Unknown unicode block {0}", value); return(BuildEpsilonNFA()); } // build the result NFA automata = NFA.NewMinimal(); AddUnicodeSpanToNFA(automata, block.Span); return(automata); }
//--------------------------------------------------------------------// // M e t h o d // // c b U n i c o d e C p _ S e l e c t i o n C h a n g e d // //--------------------------------------------------------------------// // // // Code-point item has changed. // // // //--------------------------------------------------------------------// private void cbUnicodeCp_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (_initialised) { String utf8HexVal = ""; UInt32 unicodeUCS2; unicodeUCS2 = (UInt32)((cbUnicodeCp01.SelectedIndex * 256) + cbUnicodeCp02.SelectedIndex); String unicodeBlock = UnicodeBlocks.getBlocknameForCodepoint(unicodeUCS2); UnicodeCategory unicodeCat = CharUnicodeInfo.GetUnicodeCategory((Char)unicodeUCS2); if (_crntPDL == ToolCommonData.ePrintLang.PCL) { _unicodeUCS2PCL = unicodeUCS2; } else { _unicodeUCS2PCLXL = unicodeUCS2; } PrnParseDataUTF8.convertUTF32ToUTF8HexString(unicodeUCS2, true, ref utf8HexVal); txtUnicodeUTF8.Text = utf8HexVal; txtUnicodeBlock.Text = unicodeBlock; txtUnicodeCat.Text = unicodeCat.ToString(); } }