<?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>19941</bug_id>
          
          <creation_ts>2012-11-11 22:58:29 +0000</creation_ts>
          <short_desc>Premature shift to two-byte mode in stateful encoders?</short_desc>
          <delta_ts>2013-01-15 10:13:22 +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>Encoding</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Windows 3.1</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></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>pub-w3</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>mike</cc>
    
    <cc>VYV03354</cc>
          
          <qa_contact>sideshowbarker+encodingspec</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>78209</commentid>
    <comment_count>0</comment_count>
    <who name="">pub-w3</who>
    <bug_when>2012-11-11 22:58:29 +0000</bug_when>
    <thetext>The hz-gb-2312 encoder shifts to two-byte mode (i.e., emits the shift sequence ~{ or 7E 7B) whenever a non-ASCII character is seen (and the encoder is not in two-byte mode already), without checking whether the character is actually encodable (part of GB2312).  If it is not, an encoder error will be emitted next, which means that 1) for a terminating encoder, the output will end with a useless shift sequence, and 2) for a non-terminating encoder, the two-byte shift will have to be followed immediately by a one-byte (ASCII) shift (~} or 7E 7D) before the ASCII representation of the unrepresentable character.

It seems better not to output shift sequences with no purpose.

This issue also applies to the encoders for ISO-2022-JP and ISO-2022-KR.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81331</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-01-14 11:24:21 +0000</bug_when>
    <thetext>Okay, so for the hz-gb-2312 encoder we could switch 7 and 8 and add to the new 8 the additional condition that pointer is not null.

A similar type of fix works for the other encoders as far as I can tell.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81349</commentid>
    <comment_count>2</comment_count>
    <who name="">pub-w3</who>
    <bug_when>2013-01-14 19:16:23 +0000</bug_when>
    <thetext>Yes, that should work.

Moving 7 to after 9 would be slightly simpler and might give the same result.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81383</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-01-15 10:13:22 +0000</bug_when>
    <thetext>https://github.com/whatwg/encoding/commit/488c13a91d75c6f7314076ffd861a48972ac7f6d</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>