示例#1
0
        /// <summary>
        /// Converts the specified bytes to an ASCII encoded string, treating the bytes as UTF16 encoded bytes.
        /// </summary>
        /// <param name="n">Pointer to the bytes to convert.</param>
        /// <param name="aStart">The index in the array at which to start converting bytes.</param>
        /// <param name="aCharCount">The number of characters to convert.</param>
        /// <returns>The ASCII encoded string.</returns>
        /// <remarks>
        /// This method does not handle removing the null termination character if it is present.
        /// </remarks>
        public unsafe static FOS_System.String GetASCIIStringFromUTF16(byte *n, UInt32 aStart, UInt32 aCharCount)
        {
            //If you change this method, change the array version above too.

            {
                uint maxExtent = (aCharCount * 2) + aStart;
                uint i         = aStart;
                for (; i < maxExtent; i += 2)
                {
                    if (n[i] == 0 && n[i + 1] == 0)
                    {
                        break;
                    }
                }
                aCharCount = (i - aStart) / 2;
            }

            FOS_System.String result = FOS_System.String.New((int)aCharCount);

            if (result == null)
            {
                ExceptionMethods.Throw(new Exceptions.NullReferenceException());
            }
            else
            {
                for (int i = 0; i < aCharCount; i++)
                {
                    UInt32 pos   = (UInt32)(aStart + (i * 2));
                    UInt16 aChar = (UInt16)(n[pos + 1] << 8 | n[pos]);
                    if (aChar == 0)
                    {
                        return(result.Substring(0, i));
                    }
                    result[i] = (char)aChar;
                }
            }

            return(result);
        }
示例#2
0
        public static unsafe FOS_System.String GetASCIIStringFromASCII(byte *n, UInt32 aStart, UInt32 aCharCount)
        {
            {
                uint maxExtent = (aCharCount + aStart);
                uint i         = aStart;
                for (; i < maxExtent; i++)
                {
                    if (n[i] == 0)
                    {
                        break;
                    }
                }
                aCharCount = i - aStart;
            }

            FOS_System.String result = FOS_System.String.New((int)aCharCount);

            if (result == null)
            {
                ExceptionMethods.Throw(new Exceptions.NullReferenceException());
            }
            else
            {
                for (int i = 0; i < aCharCount; i++)
                {
                    UInt32 pos   = (UInt32)(aStart + i);
                    UInt16 aChar = (UInt16)(n[pos]);
                    if (aChar == 0)
                    {
                        return(result.Substring(0, i));
                    }
                    result[i] = (char)aChar;
                }
            }

            return(result);
        }
示例#3
0
 /// <summary>
 /// Removes the mapping's prefix from the specified path.
 /// </summary>
 /// <param name="aPath">The path to remove the prefix from.</param>
 /// <returns>The path without the prefix.</returns>
 public FOS_System.String RemoveMappingPrefix(FOS_System.String aPath)
 {
     return(aPath.Substring(prefix.length, aPath.length - prefix.length));
 }