private string GetAsciiUsingOS(string unicode) { if (unicode.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_IdnBadLabelSize"), "unicode"); } string str = unicode; int index = str.Length - 1; if ((int)str[index] == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequence", (object)(unicode.Length - 1)), "unicode"); } int num = (this.AllowUnassigned ? 1 : 0) | (this.UseStd3AsciiRules ? 2 : 0); string lpUnicodeCharStr1 = unicode; int length1 = lpUnicodeCharStr1.Length; // ISSUE: variable of the null type __Null local = null; int cchASCIIChar1 = 0; int ascii1 = IdnMapping.IdnToAscii((uint)num, lpUnicodeCharStr1, length1, (char[])local, cchASCIIChar1); if (ascii1 == 0) { if (Marshal.GetLastWin32Error() == 123) { throw new ArgumentException(Environment.GetResourceString("Argument_IdnIllegalName"), "unicode"); } throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"), "unicode"); } char[] chArray = new char[ascii1]; string lpUnicodeCharStr2 = unicode; int length2 = lpUnicodeCharStr2.Length; char[] lpASCIICharStr = chArray; int cchASCIIChar2 = ascii1; int ascii2 = IdnMapping.IdnToAscii((uint)num, lpUnicodeCharStr2, length2, lpASCIICharStr, cchASCIIChar2); if (ascii2 != 0) { return(new string(chArray, 0, ascii2)); } if (Marshal.GetLastWin32Error() == 123) { throw new ArgumentException(Environment.GetResourceString("Argument_IdnIllegalName"), "unicode"); } throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"), "unicode"); }
private string GetAsciiUsingOS(string unicode) { if (unicode.Length == 0) { throw new ArgumentException(Environment.GetResourceString("Argument_IdnBadLabelSize"), "unicode"); } if (unicode[unicode.Length - 1] == '\0') { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequence", new object[] { unicode.Length - 1 }), "unicode"); } uint dwFlags = (this.AllowUnassigned ? 1U : 0U) | (this.UseStd3AsciiRules ? 2U : 0U); int num = IdnMapping.IdnToAscii(dwFlags, unicode, unicode.Length, null, 0); if (num == 0) { int lastWin32Error = Marshal.GetLastWin32Error(); if (lastWin32Error == 123) { throw new ArgumentException(Environment.GetResourceString("Argument_IdnIllegalName"), "unicode"); } throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"), "unicode"); } else { char[] array = new char[num]; num = IdnMapping.IdnToAscii(dwFlags, unicode, unicode.Length, array, num); if (num != 0) { return(new string(array, 0, num)); } int lastWin32Error = Marshal.GetLastWin32Error(); if (lastWin32Error == 123) { throw new ArgumentException(Environment.GetResourceString("Argument_IdnIllegalName"), "unicode"); } throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"), "unicode"); } }