<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>24420</bug_id>
          
          <creation_ts>2009-03-06 01:30:03 -0800</creation_ts>
          <short_desc>Consider doing encoding detection before decoding starts</short_desc>
          <delta_ts>2022-09-16 15:34:51 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=245305</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jungshik Shin">jshin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>112555</commentid>
    <comment_count>0</comment_count>
    <who name="Jungshik Shin">jshin</who>
    <bug_when>2009-03-06 01:30:03 -0800</bug_when>
    <thetext>Spun off bug 16482.

Character encoding auto-detection is done after a part of an input file is decoded. We have to find a way to do the encoding detection before any decoding starts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113405</commentid>
    <comment_count>1</comment_count>
    <who name="Jungshik Shin">jshin</who>
    <bug_when>2009-03-12 10:20:24 -0700</bug_when>
    <thetext>bug 16482 comment #30 

How about doing a similar &quot;pre-scanning&quot;(?) with auto-detection? We can ask
autodetector to  return &quot;an indicator of undeterministic/unknown) until it
reaches a confidence level higher than a certain value (that thresold should be
internal to each implementation of autodetector). Then,  we can set a flag
(similar to m_checkedForHeadCharset). Would it be a good plan for bug 24420? 
 
bug 16482 comment #31

Yes, it may we ll be. Are you well familiar with how Gecko encoding detector
works? How much data does it normally need to choose an encoding with
confidence (and how much data would you expect our detector to need)?



</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113412</commentid>
    <comment_count>2</comment_count>
    <who name="Jungshik Shin">jshin</who>
    <bug_when>2009-03-12 10:38:25 -0700</bug_when>
    <thetext>(In reply to comment #1)

&gt; bug 16482 comment #31
&gt; 
&gt; Yes, it may we ll be. Are you well familiar with how Gecko encoding detector
&gt; works? How much data does it normally need to choose an encoding with
&gt; confidence (and how much data would you expect our detector to need)?

I have an overall understanding of  Gecko&apos;s algorithms (byte unigram and byte bigram), but don&apos;t know those criteria you asked about. However, I know two (or three) people who developed them and can ask as a short cut instead of reading the source code. 

As for ICU&apos;s encoding detector, it uses byte-trigrams and my not-so-scientific experiment indicates that it can be pretty reliable after 1kB or so. Needless to say, if the first 1kB is (almost) entirely made up of ASCII bytes, it&apos;d not work as well. ICU gives back a confidence level. The way it&apos;s calculated is not so elaborate, though. So, we need to employee some heuristics when using it. 

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113416</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2009-03-12 10:51:07 -0700</bug_when>
    <thetext>Looks like ICU also has an upper limit: &lt;http://sourceforge.net/mailarchive/message.php?msg_name=49382ACE.2080804%40icu-project.org&gt;.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>