コード例 #1
0
 /// <summary>
 /// Returns true if there is a partition of the string such that this set contains each of the partitioned strings.
 /// For example, for the Unicode set [a{bc}{cd}]
 /// <list type="bullet">
 ///     <item><description><see cref="ContainsAll(UnicodeSet, string)"/> is true for each of: "a", "bc", ""cdbca"</description></item>
 ///     <item><description><see cref="ContainsAll(UnicodeSet, string)"/> is false for each of: "acb", "bcda", "bcx"</description></item>
 /// </list>
 /// </summary>
 /// <param name="set">This set.</param>
 /// <param name="s">String containing characters to be checked for containment.</param>
 /// <returns>true if the test condition is met.</returns>
 /// <draft>ICU4N 60.1</draft>
 /// <provisional>This API might change or be removed in a future release.</provisional>
 public static bool ContainsAll(this UnicodeSet set, string s)
 {
     if (set == null)
     {
         throw new ArgumentNullException(nameof(set));
     }
     return(set.ContainsAll(s));
 }
コード例 #2
0
        /// <summary>
        /// Converts the range from lastSafe to limit.
        /// </summary>
        ///
        /// <param name="verify">If non-null, check to see that all replacement characters arein it. If not, abort the conversion and returnInteger.MIN_VALUE.</param>
        /// <returns>return the delta in length (new - old), or Integer.MIN_VALUE if
        /// the verify aborted.</returns>
        internal int Convert(Replaceable text, int lastSafe, int limit, UnicodeSet verify)
        {
            // System.out.println("t: " +
            // com.ibm.icu.impl.Utility.hex(text.toString()) + ", s: " + lastSafe +
            // ", l: " + limit);

            int    len   = limit - lastSafe;
            String input = null;

            lock (buffer) {
                if (buffer.Length < len)
                {
                    buffer = new char[len];             // rare, and we don't care if we grow
                                                        // too large
                }
                text.GetChars(lastSafe, limit, buffer, 0);
                input = new String(buffer, 0, len);             // TODO: fix normalizer to take
                                                                // char[]
            }
            String output = IBM.ICU.Text.Normalizer.Normalize(input, mode, options);

            // verify OK, if specified
            if (verify != null)
            {
                bool skip = !skippable.ContainsAll(output);
                if (DEBUG)
                {
                    System.Console.Out.WriteLine(((skip) ? "  SKIP: " : "NOSKIP: ")
                                                 + IBM.ICU.Impl.Utility.Escape(input) + " => "
                                                 + IBM.ICU.Impl.Utility.Escape(output));
                }
                if (skip)
                {
                    return(Int32.MinValue);
                }
            }

            if (output.Equals(input))
            {
                return(0);
            }
            text.Replace(lastSafe, limit, output);
            return(output.Length - len);
        }
コード例 #3
0
 // might want to add to TestFmwk
 private void assertContainsAll(String message, UnicodeSet set, String str)
 {
     handleAssert(set.ContainsAll(str), message, set, str, "contains all of", false);
 }