import java.text.Collator;
import java.util.Locale;
class Decomposition {
public static void compare(Collator c, String a, String b) {
switch (c.getDecomposition()) {
case Collator.NO_DECOMPOSITION:
System.out.print(" NO DECOMPOSITION: ");
break;
case Collator.CANONICAL_DECOMPOSITION:
System.out.print(" CANONICAL DECOMPOSITION: ");
break;
case Collator.FULL_DECOMPOSITION:
System.out.print(" FULL DECOMPOSITION: ");
break;
default:
System.out.print(" UNKNOWN DECOMPOSITION: ");
}
if (c.equals(a, b))
System.out.println("The strings are equal.");
else
System.out.println("The strings are NOT equal.");
}
public static void main(String s[]) {
Collator collate = Collator.getInstance(Locale.US);
collate.setStrength(Collator.IDENTICAL);
collate.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
compare(collate, "A", "\uFF21");
}
}
|