Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we fix toLower/toUpper? #3264

Closed
pbiggar opened this issue Nov 26, 2021 · 14 comments
Closed

Can we fix toLower/toUpper? #3264

pbiggar opened this issue Nov 26, 2021 · 14 comments

Comments

@pbiggar
Copy link
Member

pbiggar commented Nov 26, 2021

The .NET toUpper/toLower do not handle some unicode issues as well as the OCaml code. I believe .NET handles "simple" Case Mapping, but not "full" Case Mapping.

This comment describes what I know.

It appears that someone wrote some code that might solve this: dotnet/runtime#30960 (comment) (links to https://gist.github.com/tarekgh/de1a1b29b03d048ad580c0a338c44fbb). We should determine if this solves it, and if so, incorporate it in String::toUpper and String::toLower

@StachuDotNet
Copy link
Member

StachuDotNet commented Mar 20, 2022

We should determine if this solves it

To check this, I:

  • created a new .sln locally, with C# src and F# test projects in it
  • copied the C# code from the gist above into the src project
  • wrote a few lines of F# to test the exposed fn there, against the relevant OCAMLONLY test cases here

image

And seemingly this doesn't not solve our situation? Or perhaps I am misinterpreting.

@pbiggar
Copy link
Member Author

pbiggar commented Mar 21, 2022

I am quite surprised it didn't work - the comments seemed to indicate a high degree of confidence that it would. But you are indeed testing the right thing afaict.

@StachuDotNet
Copy link
Member

StachuDotNet commented Mar 21, 2022

I was surprised too.
For what it's worth, I created a separate project in case you'd like to clone: https://github.com/StachuDotNet/StringCasingFix
image

Maybe it's worth mentioning in the other thread? Maybe it's specific to .NET 6?

@pbiggar
Copy link
Member Author

pbiggar commented Mar 21, 2022

Maybe it's worth mentioning in the other thread? Maybe it's specific to .NET 6?

For sure!

@StachuDotNet
Copy link
Member

StachuDotNet commented Mar 21, 2022

Maybe it's worth mentioning in the other thread? Maybe it's specific to .NET 6?

For sure!

I have a draft and would appreciate some feedback on the below, @pbiggar - still finding myself a bit lost here!


I'm attempting to use the provided gist to resolve the same (or seemingly such) issue of surprising ToUpper results noted here, in #3264, linked just before this comment.

Namely, we're hoping to find a solution that will ToUpper strings like "և" and "fifl" properly (to "ԵՒ" and "FIFL", respectively).

I've copied the code into a new .net6 project, only to find that they're not working the same as noted in the linked comment. My solution may be found here: https://github.com/StachuDotNet/StringCasingFix

This is a bit tangential, so hope I'm not distracting much, but was wondering if I'm missing something - should I expect this to work? Has something changed, perhaps related to .NET versions?

@pbiggar
Copy link
Member Author

pbiggar commented Mar 21, 2022

Here's what I'd write:


I tried the gist in .NET 6 and found that strings "և" and "fifl" did not convert to upper case properly (I was expecting "ԵՒ" and "FIFL", respectively). Here's a repo that replicates the issue.

Should I expect this to work?


And maybe tag tarekgh.

That said..

This isn't the exact same input than they were discussing, right? So there's two potential issues:

  • their code doesn't work in NET6 or some other condition in the standalone repo
  • their code never covered the input we are testing.

So it may be worth establishing which of these is the case, as that might help us to ask a better question and get a better response.

@StachuDotNet
Copy link
Member

StachuDotNet commented Mar 21, 2022

Hm. Their example of , in my solution, yields (no-op).

So, either this is an environment thing [my OS + .NET version + ???], or the gist and that comment aren't in sync, and I/we were mistakenly assuming they were.

@StachuDotNet
Copy link
Member

FWIW, on .net core 3.1, I get the same results:

Expected: 'TEST'; Actual: 'TEST'
Expected: 'FIFL'; Actual: 'fifl'
Expected: 'FFL'; Actual: 'ffi'
Expected: 'ԵՒ'; Actual: 'և'

I could set up .NET on my Windows machine and try there to rule out OS? Seems somewhat overkill, though, and now just thinking the gist doesn't match what we're looking for.

@pbiggar
Copy link
Member Author

pbiggar commented Mar 21, 2022

Yeah. Maybe let them know and we can move on if they don't respond.

@StachuDotNet
Copy link
Member

We got a response dotnet/runtime#30960 (comment)
Sounds like we misinterpreted things

@pbiggar
Copy link
Member Author

pbiggar commented Mar 22, 2022

Whoops!

What should we do here then? Close this issue?

@StachuDotNet
Copy link
Member

I've scoured the internet the best I can to find another solution here, but haven't found anything.
Theoretically, this is still possible, I presume, so closing feels a bit wrong, but likely not blocking for an F# release. So maybe let's leave the conversation here and leave it for "some day"?

@pbiggar
Copy link
Member Author

pbiggar commented Mar 22, 2022

Makes sense, thanks!

@StachuDotNet StachuDotNet removed their assignment Mar 23, 2022
@StachuDotNet
Copy link
Member

Should this be closed in favor of #3437? (or the other way around)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants