You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tika.apache.org by Kassi Bell <eb...@gmail.com> on 2009/04/03 01:43:33 UTC
What's the default encoding of Tika?
Hello guys,
I know that Tika autodetects the encoding of the characters, but, when it
parses them and converts them to plain text, what's the character encoding
of the generated converted text? Does it keep the original one? Is it UTF-8?
If it isn't, how to force it to be UTF-8?
Thanks in advance for your support.
Cheers
Re: What's the default encoding of Tika?
Posted by Jukka Zitting <ju...@gmail.com>.
Hi,
On Fri, Apr 3, 2009 at 1:43 AM, Kassi Bell <eb...@gmail.com> wrote:
> I know that Tika autodetects the encoding of the characters, but, when it
> parses them and converts them to plain text, what's the character encoding
> of the generated converted text? Does it keep the original one? Is it UTF-8?
The native text output format of Tika are the SAX character events
with arrays of Java characters. In other words we use Java's version
of the UTF-16 encoding.
The same is true also when you convert the SAX events to a String with
BodyContentHandler or to a Reader with ParsingReader.
Normally you only need to worry about the encoding when you serialize
the Tika output to a byte stream. The XML outputs from the Tika CLI
are always encoded in UTF-8, and the text output is in the platform
default encoding.
> If it isn't, how to force it to be UTF-8?
To customize the encoding of extracted text, you can construct an
OutputStreamWriter instance with a specific chraracter encoding and
pass that to the BodyContentHandler you're using to capture SAX events
from a Tika parser.
Perhaps we should add an option to the Tika CLI that explicitly
specifies the desired output encoding.
BR,
Jukka Zitting