mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-17 18:56:53 +00:00
ICU-10221 Fixed parsed length issue with a grandfathered tag in LanguageTag parser implementation.
X-SVN-Rev: 33822
This commit is contained in:
parent
6fa94941a5
commit
408820999c
1 changed files with 9 additions and 1 deletions
|
@ -163,12 +163,14 @@ public class LanguageTag {
|
|||
}
|
||||
|
||||
StringTokenIterator itr;
|
||||
boolean isGrandfathered = false;
|
||||
|
||||
// Check if the tag is grandfathered
|
||||
String[] gfmap = GRANDFATHERED.get(new AsciiUtil.CaseInsensitiveKey(languageTag));
|
||||
if (gfmap != null) {
|
||||
// use preferred mapping
|
||||
itr = new StringTokenIterator(gfmap[1], SEP);
|
||||
isGrandfathered = true;
|
||||
} else {
|
||||
itr = new StringTokenIterator(languageTag, SEP);
|
||||
}
|
||||
|
@ -185,7 +187,13 @@ public class LanguageTag {
|
|||
}
|
||||
tag.parsePrivateuse(itr, sts);
|
||||
|
||||
if (!itr.isDone() && !sts.isError()) {
|
||||
if (isGrandfathered) {
|
||||
// Grandfathered tag is replaced with a well-formed tag above.
|
||||
// However, the parsed length must be the original tag length.
|
||||
assert (itr.isDone());
|
||||
assert (!sts.isError());
|
||||
sts._parseLength = languageTag.length();
|
||||
} else if (!itr.isDone() && !sts.isError()) {
|
||||
String s = itr.current();
|
||||
sts._errorIndex = itr.currentStart();
|
||||
if (s.length() == 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue