mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 14:05:32 +00:00
ICU-20148 fix dup variant and dup ext singleton
This commit is contained in:
parent
07df49c9a9
commit
f66f0454e5
2 changed files with 33 additions and 3 deletions
|
@ -324,7 +324,11 @@ public class LanguageTag {
|
|||
if (_variants.isEmpty()) {
|
||||
_variants = new ArrayList<String>(3);
|
||||
}
|
||||
_variants.add(s);
|
||||
// Ignore repeated variant
|
||||
s = s.toUpperCase();
|
||||
if (!_variants.contains(s)) {
|
||||
_variants.add(s);
|
||||
}
|
||||
sts._parseLength = itr.currentEnd();
|
||||
itr.next();
|
||||
}
|
||||
|
@ -343,7 +347,7 @@ public class LanguageTag {
|
|||
String s = itr.current();
|
||||
if (isExtensionSingleton(s)) {
|
||||
int start = itr.currentStart();
|
||||
String singleton = s;
|
||||
String singleton = s.toLowerCase();
|
||||
StringBuilder sb = new StringBuilder(singleton);
|
||||
|
||||
itr.next();
|
||||
|
@ -367,7 +371,14 @@ public class LanguageTag {
|
|||
if (_extensions.size() == 0) {
|
||||
_extensions = new ArrayList<String>(4);
|
||||
}
|
||||
_extensions.add(sb.toString());
|
||||
// Ignore the extension if it is already in _extensions.
|
||||
boolean alreadyHas = false;
|
||||
for (String extension : _extensions) {
|
||||
alreadyHas |= extension.charAt(0) == sb.charAt(0);
|
||||
}
|
||||
if (!alreadyHas) {
|
||||
_extensions.add(sb.toString());
|
||||
}
|
||||
found = true;
|
||||
} else {
|
||||
break;
|
||||
|
|
|
@ -4099,6 +4099,25 @@ public class ULocaleTest extends TestFmwk {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestForLanguageTagBug20148() {
|
||||
ULocale uloc = ULocale.forLanguageTag("de-DE-1901-1901");
|
||||
assertEquals("ULocale.forLanguageTag(\"de-DE-1901-1901\") ",
|
||||
"de_DE_1901", uloc.getName());
|
||||
|
||||
uloc = ULocale.forLanguageTag("de-DE-1aBc-1AbC");
|
||||
assertEquals("ULocale.forLanguageTag(\"de-DE-1aBc-1AbC\") ",
|
||||
"de_DE_1ABC", uloc.getName());
|
||||
|
||||
uloc = ULocale.forLanguageTag("en-a-bbb-a-ccc");
|
||||
assertEquals("ULocale.forLanguageTag(\"en-a-bbb-a-ccc\") ",
|
||||
"en@a=bbb", uloc.getName());
|
||||
|
||||
uloc = ULocale.forLanguageTag("en-A-bbb-a-ccc");
|
||||
assertEquals("ULocale.forLanguageTag(\"en-A-bbb-a-ccc\") ",
|
||||
"en@a=bbb", uloc.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestForLanguageTagBug13776() {
|
||||
final Locale backupDefault = Locale.getDefault();
|
||||
|
|
Loading…
Add table
Reference in a new issue