Exemplo n.º 1
0
 public static int ucol_getBound(byte[] source, int sourceLength,
                                 UColBoundMode boundType, int noOfLevels, byte[] result, int resultLength,
                                 out ErrorCode status)
 {
     status = ErrorCode.NoErrors;
     if (CollatorMethods.ucol_getBound == null)
     {
         CollatorMethods.ucol_getBound = GetMethod <CollatorMethodsContainer.ucol_getBoundDelegate>(IcuI18NLibHandle, "ucol_getBound");
     }
     return(CollatorMethods.ucol_getBound(source, sourceLength, boundType, noOfLevels, result, resultLength, out status));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Produces a bound for a given sort key.
        /// </summary>
        /// <param name="sortKey">The sort key.</param>
        /// <param name="boundType">Type of the bound.</param>
        /// <param name="result">The result.</param>
        public static void GetSortKeyBound(byte[] sortKey, UColBoundMode boundType, ref byte[] result)
        {
            ErrorCode err;
            int       size = NativeMethods.ucol_getBound(sortKey, sortKey.Length, boundType, 1, result, result.Length, out err);

            if (err > 0 && err != ErrorCode.BUFFER_OVERFLOW_ERROR)
            {
                throw new Exception("Collator.GetSortKeyBound() failed with code " + err);
            }
            if (size > result.Length)
            {
                result = new byte[size + 1];
                NativeMethods.ucol_getBound(sortKey, sortKey.Length, boundType, 1, result, result.Length, out err);
                if (err != ErrorCode.NoErrors)
                {
                    throw new Exception("Collator.GetSortKeyBound() failed with code " + err);
                }
            }
        }