runtime: ToUpper not working as intended with Turkish Culture

Description

In our tests ToUpper() method returns false characters. The lowercase “i” character should be “İ” but we are getting “I” only in .NET MAUI apps. Other project types are working fine.

Steps to Reproduce

  1. Create a new .NET MAUI project (.Net 6 or preview both are same)
  2. We have added CodePages nuget (System.Text.Encoding.CodePages)
  3. Add the following code at MauiProgram.cs
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); // don't know if this helps, just tried...
            CultureInfo tr = new CultureInfo("tr-TR", false);
            string test = "i";
            var test2 = test.ToUpper(tr);
            var testResult = test2 == "İ"; // result is false because test2 is "I" instead of "İ"

Link to public reproduction project repository

https://github.com/sencagri/MauiAppToUpper

Version with bug

7.0 Release Candidate 2

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

All android versions

Did you find any workaround?

No response

Relevant log output

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 24 (18 by maintainers)

Most upvoted comments

@sencagri just fyi, upper and lower casing strings have nothing to do with the Encoding.

doing

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); // don't know if this helps, just tried... 

is not needed anyway.

Windows works fine

Reproduced this on Android; tried it on a Windows MAUI project and it works fine.