You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "Tim Allison (Jira)" <ji...@apache.org> on 2020/02/20 18:42:00 UTC

[jira] [Comment Edited] (TIKA-3048) Tika unable to parse html files with non UTF-8 charset

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

Tim Allison edited comment on TIKA-3048 at 2/20/20 6:41 PM:
------------------------------------------------------------

This is the default algorithm: try html meta encoders; if you can't find that, try the universalencodingdetection (mozilla), and if that is null, try icu4j.

{noformat}

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<properties>
    <!-- Explicitly request default parsers -->
    <parsers/>
    <encodingDetectors>
        <encodingDetector class="org.apache.tika.parser.html.HtmlEncodingDetector"/>
        <encodingDetector class="org.apache.tika.parser.txt.UniversalEncodingDetector"/>
        <encodingDetector class="org.apache.tika.parser.txt.Icu4jEncodingDetector"/>
    </encodingDetectors>
</properties>
{noformat}


was (Author: tallison@mitre.org):
This is the default algorithm: try html meta encoders; if you can't find that, try the universalencodingdetection (mozilla), and if that is null, try icu4j.

{noformat}

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<properties>
    <!-- Explicitly request default parsers -->
    <parsers/>
    <encodingDetectors>
        <encodingDetector class="org.apache.tika.parser.html.HtmlEncodingDetector">
            <params>
                <param name="markLimit" type="int">64000</param>
            </params>
        </encodingDetector>
        <encodingDetector class="org.apache.tika.parser.txt.UniversalEncodingDetector">
            <params>
                <param name="markLimit" type="int">64001</param>
            </params>
        </encodingDetector>
        <encodingDetector class="org.apache.tika.parser.txt.Icu4jEncodingDetector">
            <params>
                <param name="markLimit" type="int">64002</param>
            </params>
        </encodingDetector>
    </encodingDetectors>
</properties>
{noformat}

> Tika unable to parse html files with non UTF-8 charset
> ------------------------------------------------------
>
>                 Key: TIKA-3048
>                 URL: https://issues.apache.org/jira/browse/TIKA-3048
>             Project: Tika
>          Issue Type: Bug
>          Components: parser
>    Affects Versions: 1.9
>            Reporter: Akash
>            Priority: Major
>         Attachments: ChineseFile.html
>
>
> Tika is returning junk characters when parsing chinese characters present inside html file. Html file have charset mentioned as GB2312 explicitly.
> <head><meta http-equiv=Content-Type content="text/html; charset=gb2312"><meta name=Generator content="Microsoft Word 15 (filtered medium)">
>  
> If we remove this charset from the html meta tag, then parsing works fine.
>  
> Similar issue is observed for Arabic, Russain, Korean, Japanese, Hungarian and Spanish languages.
> Charset mentioned for each languages - 
> Hungarian - iso-8859-1
> Chinese - gb2312
> Spanish - iso-8859-1
> Russian - koi8-r
> Korean - ks_c_5601-1987
> Japanese - iso-2022-jp
> Arabic - windows-1256



--
This message was sent by Atlassian Jira
(v8.3.4#803005)