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

Fix case-related ISO country code issue #2934

Merged
merged 1 commit into from
Oct 23, 2022

Conversation

Rob-NY
Copy link
Contributor

@Rob-NY Rob-NY commented Oct 22, 2022

Short description of changes
Fixes issue relating to ISO country codes only working if provided in lower case. Now support any case combination.

CHANGELOG: ISO country codes can now be supplied in upper or lower case

Context: Fixes an issue?
Fixes issue #2933

Does this change need documentation? What needs to be documented and how?
Probably not as I think the general expectation is that the country code should not be case sensitive anyway.

Status of this Pull Request

What is missing until this pull request can be merged?

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@ann0see ann0see linked an issue Oct 22, 2022 that may be closed by this pull request
@ann0see ann0see added this to the Release 3.10.0 milestone Oct 22, 2022
@ann0see ann0see added this to Triage in Tracking (old) via automation Oct 22, 2022
@ann0see ann0see moved this from Triage to Waiting on Team in Tracking (old) Oct 22, 2022
@hoffie
Copy link
Member

hoffie commented Oct 22, 2022

CHANGELOG: Server: ISO country codes can now be supplied in upper or lower case

Copy link
Member

@hoffie hoffie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hoffie hoffie requested a review from pljones October 22, 2022 20:10
@@ -1460,7 +1460,7 @@ QLocale::Country CLocale::GetCountryCodeByTwoLetterCode ( QString sTwoLetterCode
{
QStringList vstrLocParts = qLocale.name().split ( "_" );

if ( vstrLocParts.size() >= 2 && vstrLocParts.at ( 1 ).toLower() == sTwoLetterCode )
if ( vstrLocParts.size() >= 2 && vstrLocParts.at ( 1 ).toLower() == sTwoLetterCode.toLower() )
Copy link
Collaborator

@pljones pljones Oct 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://doc.qt.io/qt-6/qlocale.html#codeToTerritory
https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements
From what I can make out, I'd be expecting upper case?

I'm wondering if line 1450 above will work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best I can tell, the QT6 code handles the case conversion so it will accept upper/lower/mixed. See https://codebrowser.dev/qt6/qtbase/src/corelib/text/qlocale.cpp.html line 157.

For QT < 6, my contribution here was to fix an immediate bug. I added exactly 10 characters to the codebase. Since the original ISO contribution forced a toLower(), I simply balanced it to solve the problem.

I have not walked up the QT code tree to see what the QT5 data for locales looks like, so unless someone wants to do that, I think it is safer to normalize the strings (upper or lower) as done here.

Tracking (old) automation moved this from Waiting on Team to In Progress Oct 23, 2022
@hoffie hoffie merged commit cfd4393 into jamulussoftware:master Oct 23, 2022
Tracking (old) automation moved this from In Progress to Done Oct 23, 2022
@pljones pljones removed this from Done in Tracking (old) Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Two letter country codes need to be in lower case to work in 3.9.1
4 participants