Repository navigation
Use Locale.ROOT for country codes and format labels - #161
Conversation
|
https://sam-cooper.medium.com/the-country-that-broke-kotlin-84bdd0afb237 https://developer.android.com/reference/java/util/Locale#ROOT
PR looks good and it's a bug that I did not see or thought about. After double checking in Android Studio it will be merged. |
ounben
left a comment
There was a problem hiding this comment.
Diff: putExtra(Intent.EXTRA_TEXT, "${record.Name}\nRecording: ${record.format.uppercase(Locale.ROOT)}")
ounben
left a comment
There was a problem hiding this comment.
Diff: val code = item.code?.uppercase(Locale.ROOT) ?: return@mapNotNull null
ounben
left a comment
There was a problem hiding this comment.
Diff: import java.util.Locale - local.ROOT
Problem
Country codes and recording formats are uppercased with the device locale. In Turkish/Azeri locales
"in".uppercase()becomes"İN"(dotted capital İ), which breaks two things:EmojiUtils.getFlagEmoji()computes the regional-indicator code points fromA–Z(codePoint - 0x41 + 0x1F1E6), so a non-ASCII letter produces a bogus symbol instead of the flag — e.g. India (IN), Italy (IT), Ireland (IE) show a wrong glyph when the stored code is lowercase.İNinstead ofIN.Fix
Use
Locale.ROOTwherever these strings are identifiers rather than display text:EmojiUtils.getFlagEmoji()normalises the code once withuppercase(Locale.ROOT).TabsScreen/SettingsScreenuppercase country codes for the flag and label withLocale.ROOT.RecordingsTabuppercases recording format labels (mp3→MP3) withLocale.ROOT.No change for Latin locales; this only removes the locale-dependent behaviour for identifier strings.
AI disclosure
This PR was authored by an AI coding agent (OpenCode, running DeepSeek V4.1 Flash) under human supervision: the change, tests and description were generated by the agent and reviewed by the contributor before submission.