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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25534</bug_id>
          
          <creation_ts>2014-05-02 11:31:11 +0000</creation_ts>
          <short_desc>HTML spec should not encourage to auto-detect UTF-8</short_desc>
          <delta_ts>2014-08-27 23:12:46 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugzilla.mozilla.org/show_bug.cgi?id=815551</see_also>
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#determining-the-character-encoding</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Masatoshi Kimura">VYV03354</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>hsivonen</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>smontagu</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>104962</commentid>
    <comment_count>0</comment_count>
    <who name="Masatoshi Kimura">VYV03354</who>
    <bug_when>2014-05-02 11:31:11 +0000</bug_when>
    <thetext>http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#determining-the-character-encoding paragraph 8 says:

 &quot;The UTF-8 encoding has a highly detectable bit pattern. Documents that contain bytes with values greater than 0x7F which match the UTF-8 pattern are very likely to be UTF-8, while documents with byte sequences that do not match it are very likely not. User-agents are therefore encouraged to search for this common encoding.&quot;

But Gecko will never follow this. See Gecko bug 815551 for details. Therefore the paragraph will only confuse readers. Luckily, &quot;Note:&quot; is not a normative part of the spec, so we can just remove it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104985</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-05-02 18:33:13 +0000</bug_when>
    <thetext>I don&apos;t understand the arguments in that bug. If you&apos;re parsing a file and you find that the page has high bits set and is valid UTF-8, but you&apos;re parsing it as Win1252, it&apos;s almost certainly being decoded wrongly. So why not at least tell the user?

If you&apos;re doing any autodetection at all, then detecting UTF-8 seems like the obvious choice.

If you&apos;re not doing any autodetection at all, then the whole step is irrelevant.

I could change the phrasing of the note to be more conditional and recommend against any sniffing at all, if you think that&apos;d made sense.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105184</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-05-06 14:27:40 +0000</bug_when>
    <thetext>We want to make the web less dependent on sniffing. And then where we think sniffing might be necessary, we try to scope it to the TLD of the site, rather than the locale of the user (as discussed on the WHATWG list).

The specification should slowly align with this as in the end making this whole thing deterministic would be great. So e.g. we found that sniffing for utf-8 is not something we need, but sniffing for Japanese might be necessary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107399</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-06-05 21:52:04 +0000</bug_when>
    <thetext>This step isn&apos;t locale-specific. I agree that making things based on the TLD and not the locale is an improvement, but I don&apos;t think that&apos;s relevant here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107424</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-06-06 08:12:40 +0000</bug_when>
    <thetext>The other problem with allowing sniffing is that if one UA starts doing it, others will have to follow if content starts depending on it.

You start with the premise that there might be such content. I am hoping we can prevent such content from growing by not sniffing and encouraging people to define their encoding.

We need to get out of the non-determinism.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107447</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-06-06 20:11:20 +0000</bug_when>
    <thetext>The argument in comment 4 is about removing step 8 entirely. That&apos;s a different bug. This bug is about the non-normative note in step 8 (for which the solution might be the last paragraph of comment 1?).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107469</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-06-07 12:56:11 +0000</bug_when>
    <thetext>Fair. We want to remove sniffing entirely, but for now we think that for Japanese we might not be able to get away with that; same for Russian/Ukrainian. Those are the last cases we might need to define sniffing for and hopefully eventually we can define an algorithm for that rather than the current setup.

So yes, last paragraph of comment 1 sounds good.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107542</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-06-09 16:51:50 +0000</bug_when>
    <thetext>I&apos;m all for that. Please do file a bug if you think we can get there!

In the meantime, I&apos;ll see about updating the note...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107569</commentid>
    <comment_count>8</comment_count>
    <who name="Henri Sivonen">hsivonen</who>
    <bug_when>2014-06-10 08:32:43 +0000</bug_when>
    <thetext>So:
 1) UTF-8 is reliably detectable when you have the whole stream to look at.
 2) With http[s], you don&apos;t have the whole stream before you are expected to display something.
 3) With http[s], you don&apos;t have tho whole stream before the encoding is expected to inherit into subresources.

My conclusion is that the encouragement to detect UTF-8 should be scoped to being a suggestion for the case where you are reading normal files (not endless streams that have a file path) from file: URLs. I think it&apos;s harmful to have it in the spec as a general suggestion in the absence of a detailed explanation of how to reconcile the sniffing with incremental parsing and encoding inheritance into subresources.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107597</commentid>
    <comment_count>9</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-06-10 16:46:11 +0000</bug_when>
    <thetext>That seems reasonable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110683</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-08-27 23:12:30 +0000</bug_when>
    <thetext>Please reopen if the new text isn&apos;t good enough.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110684</commentid>
    <comment_count>11</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-08-27 23:12:46 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8722.
Check-in comment: Adjust notes on encoding detection
http://html5.org/tools/web-apps-tracker?from=8721&amp;to=8722</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>