3

I wrote an example console application:

  1. Get current DotNet version
  2. Then get ASCII from latine string (each label equals to or less 63 symbols long, total string length (including dots) is 254 symbols long)
static void Main(string[] args)
{
    Console.WriteLine("Environment.Version: " + Environment.Version);

    new IdnMapping().GetAscii(
        "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss." +
        "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss." +
        "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss." +
        "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss");

    Console.WriteLine("Hello World!");
}

When I run program on .Net Core 3.1 output is:

Environment.Version: 3.1.13
Hello World!

When I run program on .Net 5.0 output is:

Environment.Version: 5.0.9
Unhandled exception. System.ArgumentException: Decoded string is not a valid IDN name. (Parameter 'unicode')
   at System.Globalization.IdnMapping.IcuGetAsciiCore(String unicodeString, Char* unicode, Int32 count)
   at System.Globalization.IdnMapping.GetAscii(String unicode, Int32 index, Int32 count)
   at System.Globalization.IdnMapping.GetAscii(String unicode, Int32 index)
   at System.Globalization.IdnMapping.GetAscii(String unicode)
   at Program.Main(String[] args)

Are there any breaking changes in DotNet 5 for IdnMapping? What requirements should be for an input string?

1 Answers1

0

.NET 3.1 uses NLS (National Language Support) APIs on Windows and ICU (International Components for Unicode) library on Unix, which results in some behavioral differences when running applications on different platforms

.NET 5.0 uses ICU library, so some behavior for IDN is different from .NET 3.1 https://learn.microsoft.com/en-us/dotnet/core/extensions/globalization-icu