ICU-8606 add Normalizer2.getCombiningClass(c)
X-SVN-Rev: 30261
This commit is contained in:
parent
a1c626ed90
commit
e95274d0a4
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2009-2010, International Business Machines
|
||||
* Copyright (C) 2009-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -129,6 +129,11 @@ public final class Norm2AllModes {
|
||||
return impl.getDecomposition(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCombiningClass(int c) {
|
||||
return impl.getCC(impl.getNorm16(c));
|
||||
}
|
||||
|
||||
// quick checks
|
||||
@Override
|
||||
public boolean isNormalized(CharSequence s) {
|
||||
|
@ -492,8 +492,7 @@ public final class UCharacterProperty
|
||||
new IntProperty(0, BLOCK_MASK_, BLOCK_SHIFT_),
|
||||
new CombiningClassIntProperty(SRC_NFC) { // CANONICAL_COMBINING_CLASS
|
||||
int getValue(int c) {
|
||||
Normalizer2Impl impl = Norm2AllModes.getNFCInstance().impl;
|
||||
return impl.getCC(impl.getNorm16(c));
|
||||
return Norm2AllModes.getNFCInstance().decomp.getCombiningClass(c);
|
||||
}
|
||||
},
|
||||
new IntProperty(2, DECOMPOSITION_TYPE_MASK_, 0),
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010, International Business Machines
|
||||
* Copyright (C) 2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -684,7 +684,7 @@ public final class UTS46 extends IDNA {
|
||||
int j=i;
|
||||
c=Character.codePointBefore(label, j);
|
||||
j-=Character.charCount(c);
|
||||
if(UCharacter.getCombiningClass(c)==9) {
|
||||
if(uts46Norm2.getCombiningClass(c)==9) {
|
||||
continue;
|
||||
}
|
||||
// check precontext (Joining_Type:{L,D})(Joining_Type:T)*
|
||||
|
@ -16,7 +16,6 @@ import java.util.Map;
|
||||
|
||||
import com.ibm.icu.impl.IllegalIcuArgumentException;
|
||||
import com.ibm.icu.impl.Norm2AllModes;
|
||||
import com.ibm.icu.impl.Normalizer2Impl;
|
||||
import com.ibm.icu.impl.Trie2;
|
||||
import com.ibm.icu.impl.UBiDiProps;
|
||||
import com.ibm.icu.impl.UCaseProps;
|
||||
@ -3890,8 +3889,7 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
|
||||
if (ch < MIN_VALUE || ch > MAX_VALUE) {
|
||||
throw new IllegalArgumentException("Codepoint out of bounds");
|
||||
}
|
||||
Normalizer2Impl impl = Norm2AllModes.getNFCInstance().impl;
|
||||
return impl.getCC(impl.getNorm16(ch));
|
||||
return Norm2AllModes.getNFCInstance().decomp.getCombiningClass(ch);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2009-2010, International Business Machines
|
||||
* Copyright (C) 2009-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -89,6 +89,16 @@ public class FilteredNormalizer2 extends Normalizer2 {
|
||||
return set.contains(c) ? norm2.getDecomposition(c) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @draft ICU 49
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
@Override
|
||||
public int getCombiningClass(int c) {
|
||||
return set.contains(c) ? norm2.getCombiningClass(c) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @stable ICU 4.4
|
||||
|
@ -208,6 +208,17 @@ public abstract class Normalizer2 {
|
||||
*/
|
||||
public abstract String getDecomposition(int c);
|
||||
|
||||
/**
|
||||
* Gets the combining class of c.
|
||||
* The default implementation returns 0
|
||||
* but all standard implementations return the Unicode Canonical_Combining_Class value.
|
||||
* @param c code point
|
||||
* @return c's combining class
|
||||
* @draft ICU 49
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public int getCombiningClass(int c) { return 0; }
|
||||
|
||||
/**
|
||||
* Tests if the string is normalized.
|
||||
* Internally, in cases where the quickCheck() method would return "maybe"
|
||||
|
@ -684,6 +684,8 @@ public final class UCharacterTest extends TestFmwk
|
||||
type = 0,
|
||||
dir = 0;
|
||||
|
||||
Normalizer2 nfkc = Normalizer2.getInstance(null, "nfkc", Normalizer2.Mode.COMPOSE);
|
||||
|
||||
try
|
||||
{
|
||||
BufferedReader input = TestUtil.getDataReader(
|
||||
@ -758,6 +760,12 @@ public final class UCharacterTest extends TestFmwk
|
||||
"class " + cc);
|
||||
break;
|
||||
}
|
||||
if (nfkc.getCombiningClass(ch) != cc)
|
||||
{
|
||||
errln("FAIL \\u" + hex(ch) + " expected NFKC combining " +
|
||||
"class " + cc);
|
||||
break;
|
||||
}
|
||||
|
||||
// testing the direction
|
||||
if (d.length() == 1)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -2572,4 +2572,19 @@ public class BasicTest extends TestFmwk {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void TestFilteredNormalizer2() {
|
||||
Normalizer2 nfcNorm2=Normalizer2.getInstance(null, "nfc", Normalizer2.Mode.COMPOSE);
|
||||
UnicodeSet filter=new UnicodeSet("[^\u00a0-\u00ff\u0310-\u031f]");
|
||||
FilteredNormalizer2 fn2=new FilteredNormalizer2(nfcNorm2, filter);
|
||||
int c;
|
||||
for(c=0; c<=0x3ff; ++c) {
|
||||
int expectedCC= filter.contains(c) ? nfcNorm2.getCombiningClass(c) : 0;
|
||||
int cc=fn2.getCombiningClass(c);
|
||||
assertEquals(
|
||||
"FilteredNormalizer2(NFC, ^A0-FF,310-31F).getCombiningClass(U+"+hex(c)+
|
||||
")==filtered NFC.getCC()",
|
||||
expectedCC, cc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user