dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

Lack of documentation for encoding fallbacks

Open ulrj opened this issue 6 months ago • 3 comments

Description

Hi

neither me not copilot found any documentation why the following program (in particular the GetBytes part) does what it does and if there are other character replacements. I think there should be a full table of character replacements applied somewhere documented or easily retrievable in code.

using System;
using System.Text;

namespace EncodingFun1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Encoding.Latin1.GetString(Encoding.Latin1.GetBytes("© Š š Ž ž Œ œ Ÿ €")));
            Console.ReadKey();
        }
    }
}

Copilot asked me to report this here. So I did.

Best Regards

Marc

Reproduction Steps

Encoding.Latin1.GetBytes("Š")[0]; // returns 83 and not 63. This is fine, but needs documentation.

Expected behavior

documented behavior

Actual behavior

undocumented behavior

Regression?

no.

Known Workarounds

guessing.

Configuration

No response

Other information

No response

ulrj avatar Jul 07 '25 19:07 ulrj