From 584d0330676f1f707a7b139bda56133f892f276b Mon Sep 17 00:00:00 2001 From: Ram Viswanadha Date: Tue, 16 Oct 2001 00:18:28 +0000 Subject: [PATCH] ICU-19 Ignore bogus locale names. X-SVN-Rev: 6253 --- icu4j/src/com/ibm/icu/dev/test/lang/TestUScript.java | 3 +++ icu4j/src/com/ibm/icu/lang/UScript.java | 5 +++-- icu4j/src/com/ibm/icu/test/text/TestUScript.java | 3 +++ icu4j/src/com/ibm/text/UScript.java | 5 +++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/icu4j/src/com/ibm/icu/dev/test/lang/TestUScript.java b/icu4j/src/com/ibm/icu/dev/test/lang/TestUScript.java index 47f68d8e26..c1f67f173c 100755 --- a/icu4j/src/com/ibm/icu/dev/test/lang/TestUScript.java +++ b/icu4j/src/com/ibm/icu/dev/test/lang/TestUScript.java @@ -28,6 +28,8 @@ public class TestUScript extends TestFmwk{ new Locale("te","IN"), new Locale("hi",""), new Locale("he",""), new Locale("ar",""), + new Locale("abcde",""), + new Locale("abcde","cdef") }; final int[] expected ={ /* locales should return */ @@ -35,6 +37,7 @@ public class TestUScript extends TestFmwk{ UScript.CYRILLIC, UScript.TAMIL, UScript.TELUGU,UScript.DEVANAGARI, UScript.HEBREW, UScript.ARABIC, + UScript.INVALID_CODE,UScript.INVALID_CODE }; int i =0; int numErrors =0; diff --git a/icu4j/src/com/ibm/icu/lang/UScript.java b/icu4j/src/com/ibm/icu/lang/UScript.java index 47927f15f6..c82c442dec 100755 --- a/icu4j/src/com/ibm/icu/lang/UScript.java +++ b/icu4j/src/com/ibm/icu/lang/UScript.java @@ -762,7 +762,7 @@ public final class UScript { } private static final String localeScript = "com.ibm.text.resources.LocaleScript"; - + private static int findCodeFromLocale(Locale locale) throws MissingResourceException{ //TODO: Currently we use a hacked fallback mechanism. @@ -779,12 +779,13 @@ public final class UScript { code = scriptNameCodes[strIndex]; } }catch(MissingResourceException e){ + /* handle fallback */ int index = temp.indexOf('_'); if(index >0){ temp = temp.substring(0,index); }else{ - temp = "root"; + break; } continue; } diff --git a/icu4j/src/com/ibm/icu/test/text/TestUScript.java b/icu4j/src/com/ibm/icu/test/text/TestUScript.java index 47f68d8e26..c1f67f173c 100755 --- a/icu4j/src/com/ibm/icu/test/text/TestUScript.java +++ b/icu4j/src/com/ibm/icu/test/text/TestUScript.java @@ -28,6 +28,8 @@ public class TestUScript extends TestFmwk{ new Locale("te","IN"), new Locale("hi",""), new Locale("he",""), new Locale("ar",""), + new Locale("abcde",""), + new Locale("abcde","cdef") }; final int[] expected ={ /* locales should return */ @@ -35,6 +37,7 @@ public class TestUScript extends TestFmwk{ UScript.CYRILLIC, UScript.TAMIL, UScript.TELUGU,UScript.DEVANAGARI, UScript.HEBREW, UScript.ARABIC, + UScript.INVALID_CODE,UScript.INVALID_CODE }; int i =0; int numErrors =0; diff --git a/icu4j/src/com/ibm/text/UScript.java b/icu4j/src/com/ibm/text/UScript.java index 47927f15f6..c82c442dec 100755 --- a/icu4j/src/com/ibm/text/UScript.java +++ b/icu4j/src/com/ibm/text/UScript.java @@ -762,7 +762,7 @@ public final class UScript { } private static final String localeScript = "com.ibm.text.resources.LocaleScript"; - + private static int findCodeFromLocale(Locale locale) throws MissingResourceException{ //TODO: Currently we use a hacked fallback mechanism. @@ -779,12 +779,13 @@ public final class UScript { code = scriptNameCodes[strIndex]; } }catch(MissingResourceException e){ + /* handle fallback */ int index = temp.indexOf('_'); if(index >0){ temp = temp.substring(0,index); }else{ - temp = "root"; + break; } continue; }