ICU-9014 make hasScript(c, sc) == sc in scx(c)

X-SVN-Rev: 31331
This commit is contained in:
Markus Scherer 2012-02-06 20:11:43 +00:00
parent bf7701a030
commit 3fd6a0e7f2
2 changed files with 10 additions and 19 deletions

View File

@ -1027,18 +1027,18 @@ public final class UScript {
} }
/** /**
* Is code point c used in script sc? * Do the Script_Extensions of code point c contain script sc?
* That is, does code point c have the Script property value sc, * If c does not have explicit Script_Extensions, then this tests whether
* or do code point c's Script_Extensions include script code sc? * c has the Script property value sc.
* *
* Some characters are commonly used in multiple scripts. * <p>Some characters are commonly used in multiple scripts.
* For more information, see UAX #24: http://www.unicode.org/reports/tr24/. * For more information, see UAX #24: http://www.unicode.org/reports/tr24/.
* *
* The Script_Extensions property is provisional. It may be modified or removed * <p>The Script_Extensions property is provisional. It may be modified or removed
* in future versions of the Unicode Standard, and thus in ICU. * in future versions of the Unicode Standard, and thus in ICU.
* @param c code point * @param c code point
* @param sc script code * @param sc script code
* @return true if Script(c)==sc or sc is in Script_Extensions(c) * @return true if sc is in Script_Extensions(c)
* @draft ICU 4.6 * @draft ICU 4.6
* @provisional This API might change or be removed in a future release. * @provisional This API might change or be removed in a future release.
*/ */
@ -1050,18 +1050,9 @@ public final class UScript {
char[] scriptExtensions=UCharacterProperty.INSTANCE.m_scriptExtensions_; char[] scriptExtensions=UCharacterProperty.INSTANCE.m_scriptExtensions_;
int scx=scriptX&UCharacterProperty.SCRIPT_MASK_; // index into scriptExtensions int scx=scriptX&UCharacterProperty.SCRIPT_MASK_; // index into scriptExtensions
int script; if(scriptX>=UCharacterProperty.SCRIPT_X_WITH_OTHER) {
if(scriptX<UCharacterProperty.SCRIPT_X_WITH_INHERITED) {
script=UScript.COMMON;
} else if(scriptX<UCharacterProperty.SCRIPT_X_WITH_OTHER) {
script=UScript.INHERITED;
} else {
script=scriptExtensions[scx];
scx=scriptExtensions[scx+1]; scx=scriptExtensions[scx+1];
} }
if(sc==script) {
return true;
}
if(sc>0x7fff) { if(sc>0x7fff) {
// Guard against bogus input that would // Guard against bogus input that would
// make us go past the Script_Extensions terminator. // make us go past the Script_Extensions terminator.

View File

@ -341,7 +341,7 @@ public class TestUScript extends TestFmwk {
errln("UScript.hasScript(U+063F, ...) is wrong"); errln("UScript.hasScript(U+063F, ...) is wrong");
} }
if(!( if(!(
UScript.hasScript(0x0640, UScript.COMMON) && /* main Script value */ !UScript.hasScript(0x0640, UScript.COMMON) && /* main Script value */
UScript.hasScript(0x0640, UScript.ARABIC) && UScript.hasScript(0x0640, UScript.ARABIC) &&
UScript.hasScript(0x0640, UScript.SYRIAC) && UScript.hasScript(0x0640, UScript.SYRIAC) &&
!UScript.hasScript(0x0640, UScript.THAANA)) !UScript.hasScript(0x0640, UScript.THAANA))
@ -349,7 +349,7 @@ public class TestUScript extends TestFmwk {
errln("UScript.hasScript(U+0640, ...) is wrong"); errln("UScript.hasScript(U+0640, ...) is wrong");
} }
if(!( if(!(
UScript.hasScript(0x0650, UScript.INHERITED) && /* main Script value */ !UScript.hasScript(0x0650, UScript.INHERITED) && /* main Script value */
UScript.hasScript(0x0650, UScript.ARABIC) && UScript.hasScript(0x0650, UScript.ARABIC) &&
UScript.hasScript(0x0650, UScript.SYRIAC) && UScript.hasScript(0x0650, UScript.SYRIAC) &&
!UScript.hasScript(0x0650, UScript.THAANA)) !UScript.hasScript(0x0650, UScript.THAANA))
@ -357,7 +357,7 @@ public class TestUScript extends TestFmwk {
errln("UScript.hasScript(U+0650, ...) is wrong"); errln("UScript.hasScript(U+0650, ...) is wrong");
} }
if(!( if(!(
UScript.hasScript(0x0660, UScript.COMMON) && /* main Script value */ !UScript.hasScript(0x0660, UScript.COMMON) && /* main Script value */
UScript.hasScript(0x0660, UScript.ARABIC) && UScript.hasScript(0x0660, UScript.ARABIC) &&
!UScript.hasScript(0x0660, UScript.SYRIAC) && !UScript.hasScript(0x0660, UScript.SYRIAC) &&
UScript.hasScript(0x0660, UScript.THAANA)) UScript.hasScript(0x0660, UScript.THAANA))