Harmony
  1. Harmony
  2. HARMONY-45

Charset.isRegistered() method always return true

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None

      Description

      In accordance with J2SE specification method isRegistered() should return true only if charset is registered with IANA.
      As well, "if a supported charset is not listed in the IANA registry then its canonical name must begin with one of the strings "X-" or "x-"
      Testcase shows that even if charset name begin with "x-" isRegistered returns true;

        Activity

        Hide
        Tim Ellison added a comment -

        Validated by Vladimir.

        Show
        Tim Ellison added a comment - Validated by Vladimir.
        Hide
        Vladimir Strigun added a comment -

        I'm ok with this fix.

        Show
        Vladimir Strigun added a comment - I'm ok with this fix.
        Hide
        Tim Ellison added a comment -

        Vladimir,

        Fixed in NIO_CHAR java.nio.charset.Charset at repo revision 373510.

        Please check this fully resolves your problem.

        Show
        Tim Ellison added a comment - Vladimir, Fixed in NIO_CHAR java.nio.charset.Charset at repo revision 373510. Please check this fully resolves your problem.
        Hide
        Vladimir Strigun added a comment -

        Patch is trivial (just check whether the name of charset starts with "x-"):
        567c567
        < return true;

        > return ! canonicalName.startsWith("x-") && ! canonicalName.startsWith("X-");

        Show
        Vladimir Strigun added a comment - Patch is trivial (just check whether the name of charset starts with "x-"): 567c567 < return true; — > return ! canonicalName.startsWith("x-") && ! canonicalName.startsWith("X-");
        Hide
        Vladimir Strigun added a comment -

        Testcase:

        package org.apache.harmony.tests.java.nio.charset;

        import java.nio.charset.Charset;

        import junit.framework.TestCase;

        public class CharsetTest extends TestCase {

        /**

        • @tests java.nio.charset.Charset#isRegistered()
          */
          public void test_isRegistered() { Charset charset = Charset.forName("x-mac-cyrillic"); assertFalse("Assert 0: isRegistered() return true for \"x-mac-cyrillic\" charset ", charset.isRegistered()); charset = Charset.forName("US-ASCII"); assertTrue("Assert 1: isRegistered() return false for \"US-ASCII\" charset ", charset.isRegistered()); }

        }

        Show
        Vladimir Strigun added a comment - Testcase: package org.apache.harmony.tests.java.nio.charset; import java.nio.charset.Charset; import junit.framework.TestCase; public class CharsetTest extends TestCase { /** @tests java.nio.charset.Charset#isRegistered() */ public void test_isRegistered() { Charset charset = Charset.forName("x-mac-cyrillic"); assertFalse("Assert 0: isRegistered() return true for \"x-mac-cyrillic\" charset ", charset.isRegistered()); charset = Charset.forName("US-ASCII"); assertTrue("Assert 1: isRegistered() return false for \"US-ASCII\" charset ", charset.isRegistered()); } }

          People

          • Assignee:
            Tim Ellison
            Reporter:
            Vladimir Strigun
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development