-
Notifications
You must be signed in to change notification settings - Fork 222
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
Conversation
CHANGELOG: Server: ISO country codes can now be supplied in upper or lower case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -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() ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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