]> granicus.if.org Git - icu/commit
ICU-20098 Fix BCP47 validity check for extlang and privateuse singleton (#102)
authorjungshik <jungshik@users.noreply.github.com>
Tue, 11 Sep 2018 06:45:14 +0000 (23:45 -0700)
committerShane Carr <shane@unicode.org>
Thu, 27 Sep 2018 21:27:39 +0000 (14:27 -0700)
commit5cfdf4a519fd6aba1833eb7eccaba1939220669b
treef3acb2fe7eb2b21e1ddf88df29a54bd9e3256c7b
parent378b04c1b2e715645bdee1edb7dd55775ca9ef22
ICU-20098 Fix BCP47 validity check for extlang and privateuse singleton (#102)

* ICU-20098 Fix the validty check for extlang in uloc_forLanguageTag

BCP 47 has the following for language. extlang subtag can only be
preceded by 2*3ALPHA. Add a check for the length of language subtag
before extlang subtag.

language      = 2*3ALPHA            ; shortest ISO 639 code
                 ["-" extlang]       ; sometimes followed by
                                     ; extended language subtags
               / 4ALPHA              ; or reserved for future use
               / 5*8ALPHA            ; or registered language subtag

 extlang       = 3ALPHA              ; selected ISO 639 codes
                 *2("-" 3ALPHA)      ; permanently reserved}}

With this change, 'hant-cmn-CN' would drop '-cmn-CN' keeping only
'hant'.

* ICU-20098 Fix the validty check for extlang for ICU4J

* ICU-20098 Fix the compiler failure for ICU4J

* ICU-20098 Fix a compile error and test.

* ICU-20098 Add a test for invalid private use  singleton

ICU4C's check for private use singleton subtag ('x') is wrong and
treats invalid language tags as valid.

ICU4J's check is correct and does not require any change.

Fix that and add tests to both ICU4C and ICU4J.
icu4c/source/common/uloc_tag.cpp
icu4c/source/test/cintltst/cloctst.c
icu4j/main/classes/core/src/com/ibm/icu/impl/locale/LanguageTag.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java