/// <seealso cref="Transliterator.AddSourceTargetSet(UnicodeSet, UnicodeSet, UnicodeSet)"/> public override void AddSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet) { // Each form consists of a prefix, suffix, // * radix, minimum digit count, and maximum digit count. These // * values are stored as a five character header. ... UnicodeSet myFilter = GetFilterAsUnicodeSet(inputFilter); UnicodeSet items = new UnicodeSet(); StringBuilder buffer = new StringBuilder(); for (int i = 0; spec[i] != END;) { // first 5 items are header int end = i + spec[i] + spec[i + 1] + 5; int radix = spec[i + 2]; for (int j = 0; j < radix; ++j) { Utility.AppendNumber(buffer, j, radix, 0); } // then add the characters for (int j = i + 5; j < end; ++j) { items.Add(spec[j]); } // and go to next block i = end; } items.AddAll(buffer.ToString()); items.RetainAll(myFilter); if (items.Count > 0) { sourceSet.AddAll(items); targetSet.AddAll(0, 0x10FFFF); // assume we can produce any character } }
/// <seealso cref="Transliterator.AddSourceTargetSet(UnicodeSet, UnicodeSet, UnicodeSet)"/> public override void AddSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet) { UnicodeSet myFilter = GetFilterAsUnicodeSet(inputFilter); if (!myFilter.ContainsAll(UnicodeNameTransliterator.OPEN_DELIM) || !myFilter.Contains(CLOSE_DELIM)) { return; // we have to contain both prefix and suffix } UnicodeSet items = new UnicodeSet() .AddAll('0', '9') .AddAll('A', 'F') .AddAll('a', 'z') // for controls .Add('<').Add('>') // for controls .Add('(').Add(')') // for controls .Add('-') .Add(' ') .AddAll(UnicodeNameTransliterator.OPEN_DELIM) .Add(CLOSE_DELIM); items.RetainAll(myFilter); if (items.Count > 0) { sourceSet.AddAll(items); // could produce any character targetSet.AddAll(0, 0x10FFFF); } }
/// <summary> /// Retains EACH of the characters in this string. Note: "ch" == {"c", "h"} /// If this set already any particular character, it has no effect on that character. /// </summary> /// <param name="set">This set.</param> /// <param name="s">The source string.</param> /// <returns>This object, for chaining.</returns> /// <draft>ICU4N 60.1</draft> /// <provisional>This API might change or be removed in a future release.</provisional> public static UnicodeSet RetainAll(this UnicodeSet set, ICharSequence s) { if (set == null) { throw new ArgumentNullException(nameof(set)); } return(set.RetainAll(s)); }
/// <summary> /// Retains EACH of the characters in this string. Note: "ch" == {"c", "h"} /// If this set already any particular character, it has no effect on that character. /// </summary> /// <param name="set">This set.</param> /// <param name="s">The source string.</param> /// <returns>This object, for chaining.</returns> /// <draft>ICU4N 60.1</draft> /// <provisional>This API might change or be removed in a future release.</provisional> public static UnicodeSet RetainAll(this UnicodeSet set, StringBuilder s) { if (set == null) { throw new ArgumentNullException(nameof(set)); } return(set.RetainAll(s)); }
/// <seealso cref="UnicodeSet.RetainAll(UnicodeSet)"/> /// <draft>ICU4N 60.1</draft> /// <provisional>This API might change or be removed in a future release.</provisional> public static UnicodeSet RetainAll <T>(this UnicodeSet set, IEnumerable <T> collection) where T : ICharSequence { if (set == null) { throw new ArgumentNullException(nameof(set)); } return(set.RetainAll(collection)); }
/// <seealso cref="UnicodeSet.RetainAll(UnicodeSet)"/> /// <draft>ICU4N 60.1</draft> /// <provisional>This API might change or be removed in a future release.</provisional> public static UnicodeSet RetainAll(this UnicodeSet set, IEnumerable <char[]> collection) { if (set == null) { throw new ArgumentNullException(nameof(set)); } return(set.RetainAll(collection)); }