Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6739127

Collator.equals gives incorrect results for Nordic locales

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      Java SE 1.6.0_07

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP SP3

      A DESCRIPTION OF THE PROBLEM :
      Collator.equals method gives incorrect results for comparisons in Finnish and Swedish locales. The method equates e.g. the Finnish word "pässi" (goat) with the word "passi" passport. There's no relation with the sounds that the characters "ä" and "a" represent in the language so it's illegal to equate the characters. Equating them will always result in change or loss of meaning.

      The scandinavian characters are different from the accented characters used e.g. in some latin based languages such as french in that these characters (ä, ö, å) represent entirely independent sounds in the language and therefore cannot be represented with any other sound without change of meaning. It is therefore illegal to replace these characters with any other character.

      This means for example that you can't change the finnish word sää (weather) to saa (will have) because these are two entirely different words with different meaning. The same applies to scandinavian languages as well.

      There's no connection between the sounds represented by ä and a; ö and o or å and a.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      see source code below

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      eq: false
      eq: false

      ACTUAL -
      eq: true
      eq: true


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Locale finnish = new Locale("fi_FI");
      java.text.Collator fi = java.text.Collator.getInstance(finnish);
      fi.setStrength(java.text.Collator.PRIMARY);
      System.out.println("eq: "+fi.equals("pässi", "passi"));

      Locale swedish = new Locale("se_SE");
      java.text.Collator se = java.text.Collator.getInstance(swedish);
      se.setStrength(java.text.Collator.PRIMARY);
      System.out.println("eq: "+se.equals("kön", "kon"));


      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            jennyh Jenny Huang (Inactive)
            Reporter:
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: