System.Globalization.IdnMapping.GetUnicodeCore C# (CSharp) Method

GetUnicodeCore() private method

private GetUnicodeCore ( char ascii, int count ) : string
ascii char
count int
return string
        private unsafe string GetUnicodeCore(char* ascii, int count)
        {
            uint flags = Flags;

            // Determine the required length
            int length = Interop.Normaliz.IdnToUnicode(flags, new IntPtr(ascii), count, IntPtr.Zero, 0);
            if (length == 0)
            {
                ThrowForZeroLength(nameof(ascii), SR.Argument_IdnIllegalName, SR.Argument_IdnBadPunycode);
            }

            // Do the conversion
            const int StackAllocThreshold = 512; // arbitrary limit to switch from stack to heap allocation
            if (length < StackAllocThreshold)
            {
                char* output = stackalloc char[length];
                return GetUnicodeCore(ascii, count, flags, output, length);
            }
            else
            {
                char[] output = new char[length];
                fixed (char* pOutput = output)
                {
                    return GetUnicodeCore(ascii, count, flags, pOutput, length);
                }
            }
        }

Same methods

IdnMapping::GetUnicodeCore ( char ascii, int count, uint flags, char output, int outputLength ) : string