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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

{
return qLocale.country();
}
Expand Down