internal static CollationElementIterator Create(RuleBasedCollator.Handle elems, string str)
        {
            ErrorCode status;
            var cei = new CollationElementIterator
            {
                _handle =
                    NativeMethods.ucol_openElements(elems,
                                                    str,
                                                    str.Length,
                                                    out status)
            };
            status.ThrowIfError();

            return cei;
        }
 public static extern void ucol_setAttribute(RuleBasedCollator.Handle collator,
                                             RuleBasedCollator.CollationAttribute attr,
                                             RuleBasedCollator.CollationAttributeValue value,
                                             out ErrorCode status);
 public static extern RuleBasedCollator.Handle ucol_safeClone(RuleBasedCollator.Handle collator,
                                                              IntPtr stackBuffer,
                                                              ref int pBufferSize,
                                                              out ErrorCode status);
 public static extern CollationElementIterator.Handle ucol_openElements(RuleBasedCollator.Handle handle,
                                                                        [MarshalAs(UnmanagedType.LPWStr)] string
                                                                            text,
                                                                        int textLength,
                                                                        out ErrorCode status);
 public static extern int ucol_getSortKey(RuleBasedCollator.Handle collator,
                                          [MarshalAs(UnmanagedType.LPWStr)] string source,
                                          int sourceLength,
                                          [Out] [MarshalAs(UnmanagedType.LPArray)] byte[] result,
                                          int resultLength);
 public static extern string ucol_getLocaleByType(RuleBasedCollator.Handle collator,
                                                  LocaleType type,
                                                  out ErrorCode status);
 public static extern IntPtr uenum_unext(RuleBasedCollator.EnumeratorHandle en,
                                         out int resultLength,
                                         out ErrorCode status);
 public static extern CollationResult ucol_strcoll(RuleBasedCollator.Handle collator,
                                                   [MarshalAs(UnmanagedType.LPWStr)] string source,
                                                   int sourceLength,
                                                   [MarshalAs(UnmanagedType.LPWStr)] string target,
                                                   int targetLength);
 public override object Clone()
 {
     var copy = new RuleBasedCollator();
     ErrorCode status;
     var bufferSize = 512;
     copy._handle = NativeMethods.ucol_safeClone(_handle, IntPtr.Zero, ref bufferSize, out status);
     status.ThrowIfError();
     return copy;
 }
 public static new Collator Create(string localeId, Fallback fallback)
 {
     var instance = new RuleBasedCollator();
     ErrorCode status;
     instance._handle = NativeMethods.ucol_open(localeId, out status);
     if (status == ErrorCode.UsingFallbackWarning && fallback == Fallback.NoFallback)
     {
         throw new ArgumentException("Could only create Collator by falling back to '" + instance._Id +
                                     "'. You can use the fallback option to create this.");
     }
     if (status == ErrorCode.InternalProgramError && fallback == Fallback.FallbackAllowed)
         instance = new RuleBasedCollator(string.Empty); // fallback to UCA
     else
     {
         try
         {
             status.ThrowIfError();
         }
         catch (Exception e)
         {
             throw new ArgumentException(
                 "Unable to create a collator using the given localeId.\nThis is likely because the ICU data file was created without collation rules for this locale. You can provide the rules yourself or replace the data dll.",
                 e);
         }
     }
     return instance;
 }