@Test
    public void testLatinDetectionHeuristics() throws Exception {
        String windows = "test\r\n";
        String unix = "test\n";
        String euro = "test \u20ac\n";

        Metadata metadata;

        metadata = new Metadata();
        parser.parse(new ByteArrayInputStream(windows.getBytes("ISO-8859-15")),
                new DefaultHandler(), metadata, new ParseContext());
        assertEquals("text/plain; charset=windows-1252", metadata.get(Metadata.CONTENT_TYPE));
        assertEquals("UniversalEncodingDetector", metadata.get(TikaCoreProperties.ENCODING_DETECTOR));
        assertEquals("windows-1252", metadata.get(TikaCoreProperties.DETECTED_ENCODING));

        metadata = new Metadata();
        parser.parse(new ByteArrayInputStream(unix.getBytes("ISO-8859-15")), new DefaultHandler(),
                metadata, new ParseContext());
        assertEquals("text/plain; charset=ISO-8859-1", metadata.get(Metadata.CONTENT_TYPE));

        metadata = new Metadata();
        parser.parse(new ByteArrayInputStream(euro.getBytes("ISO-8859-15")), new DefaultHandler(),
                metadata, new ParseContext());
        assertEquals("text/plain; charset=ISO-8859-15", metadata.get(Metadata.CONTENT_TYPE));
    }
Test for the heuristics that we use to assign an eight-bit character
encoding to mostly ASCII sequences. If a more specific match can not
be made, a string with a CR(LF) in it is most probably windows-1252,
otherwise ISO-8859-1, except if it contains the currency/euro symbol
(byte 0xa4) in which case it's more likely to be ISO-8859-15.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-text-module/src/test/java/org/apache/tika/parser/txt/TXTParserTest.java