/// <summary> /// Get the description for a given ICU code point. /// </summary> /// <param name="code">the code point to get description/name of</param> /// <param name="nameChoice">what type of information to retrieve</param> /// <param name="name">return string</param> /// <returns>length of string</returns> private static int CharName(int code, UCharNameChoice nameChoice, out string name) { const int nSize = 255; IntPtr resPtr = Marshal.AllocCoTaskMem(nSize); try { ErrorCode error; int nResult = NativeMethods.u_CharName(code, nameChoice, resPtr, nSize, out error); if (error != ErrorCode.NoErrors) { nResult = -1; name = null; } else { name = Marshal.PtrToStringAnsi(resPtr); } return(nResult); } finally { Marshal.FreeCoTaskMem(resPtr); } }