private static BreakIterator CreateBreakInstance(ULocale locale, int kind) { RuleBasedBreakIterator iter = null; ICUResourceBundle rb = ICUResourceBundle. GetBundleInstance(ICUData.ICU_BRKITR_BASE_NAME, locale, ICUResourceBundle.OpenType.LOCALE_ROOT); // // Get the binary rules. // ByteBuffer bytes = null; string typeKeyExt = null; if (kind == BreakIterator.KIND_LINE) { string lbKeyValue = locale.GetKeywordValue("lb"); if (lbKeyValue != null && (lbKeyValue.Equals("strict") || lbKeyValue.Equals("normal") || lbKeyValue.Equals("loose"))) { typeKeyExt = "_" + lbKeyValue; } } try { string typeKey = (typeKeyExt == null) ? KIND_NAMES[kind] : KIND_NAMES[kind] + typeKeyExt; string brkfname = rb.GetStringWithFallback("boundaries/" + typeKey); string rulesFileName = ICUData.ICU_BRKITR_NAME + '/' + brkfname; bytes = ICUBinary.GetData(rulesFileName); } catch (Exception e) { throw new MissingManifestResourceException(e.ToString(), e /*, "", ""*/); } // // Create a normal RuleBasedBreakIterator. // try { #pragma warning disable 612, 618 iter = RuleBasedBreakIterator.GetInstanceFromCompiledRules(bytes); #pragma warning restore 612, 618 } catch (IOException e) { // Shouldn't be possible to get here. // If it happens, the compiled rules are probably corrupted in some way. Assert.Fail(e); } // TODO: Determine valid and actual locale correctly. ULocale uloc = ULocale.ForLocale(rb.GetLocale()); iter.SetLocale(uloc, uloc); iter.BreakType = kind; // filtered break if (kind == BreakIterator.KIND_SENTENCE) { string ssKeyword = locale.GetKeywordValue("ss"); if (ssKeyword != null && ssKeyword.Equals("standard")) { ULocale @base = new ULocale(locale.GetBaseName()); return(FilteredBreakIteratorBuilder.GetInstance(@base).WrapIteratorWithFilter(iter)); } } return(iter); }