Exemplo n.º 1
0
 /// <summary>
 /// Copy the given UTF-8 byte array pointer to the destination char (UCS2) array pointer, converting
 /// UTF-8 to UCS2 along the way.
 /// </summary>
 /// <param name="dest"></param>
 /// <param name="destLength"></param>
 /// <param name="destUTF8MaxLengthInBytes"></param>
 /// <param name="src"></param>
 /// <param name="srcLength"></param>
 /// <returns></returns>
 public static CopyError Copy(char *dest, out int destLength, int destUTF8MaxLengthInBytes, byte *src, int srcLength)
 {
     if (ConversionError.None == Unicode.Utf8ToUtf16(src, srcLength, dest, out destLength, destUTF8MaxLengthInBytes))
     {
         return(CopyError.None);
     }
     return(CopyError.Truncation);
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dest"></param>
        /// <param name="destLength"></param>
        /// <param name="destUTF8MaxLengthInBytes"></param>
        /// <param name="src"></param>
        /// <param name="srcLength"></param>
        /// <returns></returns>
        public static CopyError Append(char *dest, ref ushort destLength, ushort destUTF8MaxLengthInBytes, byte *src, ushort srcLength)
        {
            var error = Unicode.Utf8ToUtf16(src, srcLength, dest + destLength, out var temp, destUTF8MaxLengthInBytes - destLength);

            destLength += (ushort)temp;
            if (error == ConversionError.None)
            {
                return(CopyError.None);
            }
            return(CopyError.Truncation);
        }