maui icon indicating copy to clipboard operation
maui copied to clipboard

ios smart quotes replacing normal double quotes when a json file is loaded with the file picker

Open softlion opened this issue 1 year ago • 3 comments

Description

Related issue: https://github.com/dotnet/maui/issues/22127

Tried workaround:

        Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("Smart", (h, v) =>
        {
	        h.PlatformView.SmartQuotesType = UIKit.UITextSmartQuotesType.No;
	        h.PlatformView.SmartDashesType = UIKit.UITextSmartDashesType.No;
	        h.PlatformView.SmartInsertDeleteType = UIKit.UITextSmartInsertDeleteType.No;
        });

Steps to Reproduce

In a maui ios app, trigger the following code. When the picker appears, select any non empty json file.

If it works as expected, a breakpoint on line "json = json.Trim...." should not trigger.

 var options = new PickOptions
{
    PickerTitle = "Select a file to import",
    FileTypes = new (
        new Dictionary<DevicePlatform, IEnumerable<string>>
        {
            { DevicePlatform.iOS, new [] { "public.json" } }, //(string) UIType.Json: used in maui, but unavailable otherwise ?!
        }),
};
    
var fileData = await FilePicker.PickAsync(options);
if (fileData != null)
{
    AppSettingsFileName = fileData.FileName;
    await using var stream = await fileData.OpenReadAsync();
    using var reader = new StreamReader(stream);
    var json = reader.ReadToEnd();

   //Workaround this issue
   if (json.Contains('«') || json.Contains('“'))
    {
        json = json.Trim('\0')
            //iPad
            .Replace((char)0xA0, ' ')
            .Replace("« ", "\"")
            .Replace(" »", "\"")
            //iPhone
            .Replace("“", "\"")
            .Replace("”", "\"")
            ;
    }
}

Link to public reproduction project repository

No response

Version with bug

8.0.91 SR9.1

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

All versions

Did you find any workaround?

Yes see above.

Relevant log output

No response

softlion avatar Oct 10 '24 09:10 softlion

We've found some similar issues:

  • #22127 , similarity score: 84%
  • #18220 , similarity score: 81%

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

similar-issues-ai[bot] avatar Oct 10 '24 09:10 similar-issues-ai[bot]

Could you provide us with sample project so that we can investigate it further? Looking forward to your reply!

jaosnz-rep avatar Oct 17 '24 07:10 jaosnz-rep

Invalid issue. Caused by the "<Editor />" widget which replaces quotes in a double way binding.

softlion avatar Oct 21 '24 07:10 softlion