tika-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Olivier M (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (TIKA-1794) TXTParser removes form feed characters
Date Mon, 16 Nov 2015 15:23:11 GMT

    [ https://issues.apache.org/jira/browse/TIKA-1794?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15006768#comment-15006768
] 

Olivier M edited comment on TIKA-1794 at 11/16/15 3:22 PM:
-----------------------------------------------------------

After some reading it seems that it is an invalid character in xml 1.0 but valid in xml 1.1:
http://www.ibiblio.org/xml/books/effectivexml/chapters/03.html

I guess Tika uses xml 1.0.

>From the link above:
"Everything you need to know about XML 1.1 can be summed up in two rules:
    Don't use it.
    .... "




was (Author: maol):
After some reading it seems that it is an invalid character in xml 1.0 but valid in xml 1.1:
http://www.ibiblio.org/xml/books/effectivexml/chapters/03.html

I guess Tika uses xml 1.0.

> TXTParser removes form feed characters
> --------------------------------------
>
>                 Key: TIKA-1794
>                 URL: https://issues.apache.org/jira/browse/TIKA-1794
>             Project: Tika
>          Issue Type: Bug
>          Components: parser
>    Affects Versions: 1.11
>         Environment: Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
>            Reporter: Olivier M
>            Priority: Minor
>              Labels: parser, txt
>         Attachments: form_feed.txt
>
>
> Just noticed that Apache Tika removes form feed characters (0C in UTF-8) when parsing
a text file.
> If I compare the hex bytes of the original file and the hex bytes of the extracted text
I can see that the 0C character is replaced by  EF BF BD which is the UTF-8 replacement character.
> {code:title=Test.java|borderStyle=solid}
> 	public static void main(String[] args) {
> 		InputStream is = null;
> 		
> 		try {
> 			is = new FileInputStream("form_feed.txt");
> 			
> 			AutoDetectParser parser = new AutoDetectParser();
> 			Writer stringWriter = new StringWriter();
> 			ContentHandler handler = new BodyContentHandler(stringWriter);
> 			Metadata metadata = new Metadata();
> 			parser.parse(is, handler, metadata);
> 			
> 			String extractedText = stringWriter.toString();
> 			System.out.println(extractedText);
> 			
> 			String hex = Hex.encodeHexString(extractedText.getBytes("UTF-8"));
> 			
> 			System.out.println(hex); //0C replaced by EFBFBD
> 		} catch (Exception e) {
> 			e.printStackTrace();
> 		} finally {
> 			IOUtils.closeQuietly(is);
> 		}
> 	}
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message