Package org.apache.abdera.i18n.text.io

Examples of org.apache.abdera.i18n.text.io.CharsetSniffingInputStream


        byte[] nobom_utf32le = {0x3C, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03};
        byte[] nobom_utf16be = {0x00, 0x3C, 0x00, 0x3F, 0x01, 0x02, 0x03};
        byte[] nobom_utf16le = {0x3C, 0x00, 0x3F, 0x00, 0x01, 0x02, 0x03};

        ByteArrayInputStream in = new ByteArrayInputStream(utf32be);
        CharsetSniffingInputStream csis = new CharsetSniffingInputStream(in);
        assertEquals("UTF-32", csis.getEncoding());
        assertTrue(csis.isBomSet());

        in = new ByteArrayInputStream(utf32le);
        csis = new CharsetSniffingInputStream(in);
        assertEquals("UTF-32", csis.getEncoding());
        assertTrue(csis.isBomSet());

        in = new ByteArrayInputStream(utf16be);
        csis = new CharsetSniffingInputStream(in);
        assertEquals("UTF-16", csis.getEncoding());
        assertTrue(csis.isBomSet());

        in = new ByteArrayInputStream(utf16le);
        csis = new CharsetSniffingInputStream(in);
        assertEquals("UTF-16", csis.getEncoding());
        assertTrue(csis.isBomSet());

        in = new ByteArrayInputStream(utf8);
        csis = new CharsetSniffingInputStream(in);
        assertEquals("UTF-8", csis.getEncoding());
        assertTrue(csis.isBomSet());

        in = new ByteArrayInputStream(nobom_utf32be);
        csis = new CharsetSniffingInputStream(in);
        assertEquals("UTF-32be", csis.getEncoding());
        assertFalse(csis.isBomSet());

        in = new ByteArrayInputStream(nobom_utf32le);
        csis = new CharsetSniffingInputStream(in);
        assertEquals("UTF-32le", csis.getEncoding());
        assertFalse(csis.isBomSet());

        in = new ByteArrayInputStream(nobom_utf16be);
        csis = new CharsetSniffingInputStream(in);
        assertEquals("UTF-16be", csis.getEncoding());
        assertFalse(csis.isBomSet());

        in = new ByteArrayInputStream(nobom_utf16le);
        csis = new CharsetSniffingInputStream(in);
        assertEquals("UTF-16le", csis.getEncoding());
        assertFalse(csis.isBomSet());
    }
View Full Code Here


    byte[] nobom_utf32le = {0x3C,0x00,0x00,0x00, 0x01, 0x02, 0x03};
    byte[] nobom_utf16be = {0x00,0x3C,0x00,0x3F, 0x01, 0x02, 0x03};
    byte[] nobom_utf16le = {0x3C,0x00,0x3F,0x00, 0x01, 0x02, 0x03};
   
    ByteArrayInputStream in = new ByteArrayInputStream(utf32be);
    CharsetSniffingInputStream csis = new CharsetSniffingInputStream(in);
    assertEquals(csis.getEncoding(),"UTF-32");
    assertTrue(csis.isBomSet());
   
    in = new ByteArrayInputStream(utf32le);
    csis = new CharsetSniffingInputStream(in);
    assertEquals(csis.getEncoding(),"UTF-32");
    assertTrue(csis.isBomSet());

    in = new ByteArrayInputStream(utf16be);
    csis = new CharsetSniffingInputStream(in);
    assertEquals(csis.getEncoding(),"UTF-16");
    assertTrue(csis.isBomSet());
   
    in = new ByteArrayInputStream(utf16le);
    csis = new CharsetSniffingInputStream(in);
    assertEquals(csis.getEncoding(),"UTF-16");
    assertTrue(csis.isBomSet());
   
    in = new ByteArrayInputStream(utf8);
    csis = new CharsetSniffingInputStream(in);
    assertEquals(csis.getEncoding(),"UTF-8");
    assertTrue(csis.isBomSet());
   

    in = new ByteArrayInputStream(nobom_utf32be);
    csis = new CharsetSniffingInputStream(in);
    assertEquals(csis.getEncoding(),"UTF-32be");
    assertFalse(csis.isBomSet());
   
    in = new ByteArrayInputStream(nobom_utf32le);
    csis = new CharsetSniffingInputStream(in);
    assertEquals(csis.getEncoding(),"UTF-32le");
    assertFalse(csis.isBomSet());

    in = new ByteArrayInputStream(nobom_utf16be);
    csis = new CharsetSniffingInputStream(in);
    assertEquals(csis.getEncoding(),"UTF-16be");
    assertFalse(csis.isBomSet());
   
    in = new ByteArrayInputStream(nobom_utf16le);
    csis = new CharsetSniffingInputStream(in);
    assertEquals(csis.getEncoding(),"UTF-16le");
    assertFalse(csis.isBomSet());
  }
View Full Code Here

TOP

Related Classes of org.apache.abdera.i18n.text.io.CharsetSniffingInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.