Collator.CANONICAL_DECOMPOSITION : Collator « I18N « Java






Collator.CANONICAL_DECOMPOSITION

  
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");
  }
}

   
  








Related examples in the same category

1.Collator.getInstance(new Locale("sv", ""))
2.Comparing Half-Width and full-width A
3.Collator.NO_DECOMPOSITION
4.Collator.FULL_DECOMPOSITION
5.Sort Collate
6.I18N SortI18N Sort
7.Searching, Sorting, and Text Boundary Detection: Collation IssuesSearching, Sorting, and Text Boundary Detection: Collation Issues
8.Compare accentuated letters
9.Check Equality for two strings with Collator
10.Sort strings using Collator class
11.I18N : TextI18N : Text