@Override public Reader openStream() throws IOException { return toReader(byteSource.openStream()); }
public void test_toReader_bomUtf16BE() throws IOException { byte[] bytes = {X_FE, X_FF, X_00, 'H', X_00, 'e', X_00, 'l', X_00, 'l', X_00, 'o'}; Reader reader = UnicodeBom.toReader(new ByteArrayInputStream(bytes)); String str = CharStreams.toString(reader); assertEquals(str, "Hello"); }
public void test_toReader_bomUtf16BE_short() throws IOException { byte[] bytes = {X_FE, X_FF}; Reader reader = UnicodeBom.toReader(new ByteArrayInputStream(bytes)); String str = CharStreams.toString(reader); assertEquals(str, ""); }
public void test_toReader_noBomUtf8() throws IOException { byte[] bytes = {'H', 'e', 'l', 'l', 'o'}; Reader reader = UnicodeBom.toReader(new ByteArrayInputStream(bytes)); String str = CharStreams.toString(reader); assertEquals(str, "Hello"); }
public void test_toReader_bomUtf8() throws IOException { byte[] bytes = {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF, 'H', 'e', 'l', 'l', 'o'}; Reader reader = UnicodeBom.toReader(new ByteArrayInputStream(bytes)); String str = CharStreams.toString(reader); assertEquals(str, "Hello"); }
public void test_toReader_bomUtf16LE() throws IOException { byte[] bytes = {X_FF, X_FE, 'H', X_00, 'e', X_00, 'l', X_00, 'l', X_00, 'o', X_00}; Reader reader = UnicodeBom.toReader(new ByteArrayInputStream(bytes)); String str = CharStreams.toString(reader); assertEquals(str, "Hello"); }
public void test_toReader_bomUtf16LE_short() throws IOException { byte[] bytes = {X_FF, X_FE}; Reader reader = UnicodeBom.toReader(new ByteArrayInputStream(bytes)); String str = CharStreams.toString(reader); assertEquals(str, ""); }
public void test_toReader_almostBomUtf16LE() throws IOException { byte[] bytes = {X_FF, X_00}; Reader reader = UnicodeBom.toReader(new ByteArrayInputStream(bytes)); String str = CharStreams.toString(reader); assertEquals(str, new String(bytes, StandardCharsets.UTF_8)); }
public void test_toReader_notBomUtf16LE() throws IOException { byte[] bytes = {X_00, X_FE, 'M', 'P'}; Reader reader = UnicodeBom.toReader(new ByteArrayInputStream(bytes)); String str = CharStreams.toString(reader); assertEquals(str, new String(bytes, StandardCharsets.UTF_8)); }
public void test_toReader_almostBomUtf16BE() throws IOException { byte[] bytes = {X_FE, X_00}; Reader reader = UnicodeBom.toReader(new ByteArrayInputStream(bytes)); String str = CharStreams.toString(reader); assertEquals(str, new String(bytes, StandardCharsets.UTF_8)); }