dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.97k stars 4.66k forks source link

net8.0-ios / net8.0-android: mtouchi18n / mandroidi18n options do not apply? #106232

Open kiddkaffeine opened 1 month ago

kiddkaffeine commented 1 month ago

Description

Per documentation, adding flags like

Reproduction Steps

  1. Create net8.0-ios or net8.0-android project.
  2. Add cjk on iOS or cjk on Android
  3. Attempt to use Shift JIS encoding, e.g.: System.Text.Encoding.GetEncoding(932)

Expected behavior

Shift JIS encoding returned.

Actual behavior

Exception thrown that encoding is not supported.

Regression?

Unknown, but possible based on workaround linked in documentation this worked in earlier .net releases and documentation is out of date.

Known Workarounds

Following https://www.nuget.org/packages/System.Text.Encoding.CodePages/#readme-body-tab and adding this:

// Register the CodePages encoding provider at application startup to enable using single and double byte encodings. Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

Seems to fix.

Configuration

No response

Other information

No response

dotnet-policy-service[bot] commented 1 month ago

Tagging subscribers to this area: @dotnet/area-system-text-encoding See info in area-owners.md if you want to be subscribed.

filipnavara commented 1 month ago

That is by design. The old options are no longer supported in modern .NET. Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); is the correct and documented way to achieve it.

kiddkaffeine commented 1 month ago

Thanks for the feedback. I'm not sure if you guys control this or not but it seems like a lot of still maintained documentation refers to this, for example:

https://learn.microsoft.com/en-us/dotnet/android/building-apps/build-properties#mandroidi18n

tarekgh commented 1 month ago

The behavior is documented in https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding.getencoding?view=net-8.0#overloads. I'll let @matouskozak @vitek-karas @mdh1418 comment on the docs https://learn.microsoft.com/en-us/dotnet/android/building-apps/build-properties#mandroidi18n.

dotnet-policy-service[bot] commented 1 month ago

Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger See info in area-owners.md if you want to be subscribed.

dotnet-policy-service[bot] commented 1 month ago

Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger See info in area-owners.md if you want to be subscribed.