dotnet / dotnet/dotnet-api-docs

Lack of documentation for encoding fallbacks

Open
#11,555 3 comments 0 reactions 0 assignees View on GitHub
area-System.Text.Encoding
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### 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.

```C#
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

```C#
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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.