<html>
    <head>
      <base href="http://bugzilla.gdcproject.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - std.enconding: EncodingSchemeUtf16Native and EncodingSchemeUtf32Native invalid splicing"
   href="http://bugzilla.gdcproject.org/show_bug.cgi?id=138">138</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std.enconding: EncodingSchemeUtf16Native and EncodingSchemeUtf32Native invalid splicing
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>GDC
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>development
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>libgphobos
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>ibuclaw@gdcproject.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ketmar@ketmar.no-ip.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=70&action=diff" name="attach_70" title="bugfix">attachment 70</a> <a href="attachment.cgi?id=70&action=edit" title="bugfix">[details]</a></span>
bugfix

as we are rapidly fixing bugs, there is another one. i reported it to mainline
DMD and they still not fixed it. but it can be fixed in gdc though.

EncodingSchemeUtf16Native.decode() and EncodingSchemeUtf32Native.decode()
should take character type size into account when chopping out decoded bytes.
patch attached. here is test case:

import std.encoding;


void testUTF16 () {
  version(LittleEndian) {
    auto efrom = EncodingScheme.create("utf-16le");
    ubyte[6] sample = [154,1, 155,1, 156,1];
  }
  version(BigEndian) {
    auto efrom = EncodingScheme.create("utf-16be");
    ubyte[6] sample = [1,154, 1,155, 1,156];
  }
  const(ubyte)[] ub = cast(const(ubyte)[])sample;
  dchar dc = efrom.safeDecode(ub);
  assert(dc == 410);
  assert(ub.length == 4);
}


void testUTF32 () {
  version(LittleEndian) {
    auto efrom = EncodingScheme.create("utf-32le");
    ubyte[12] sample = [154,1,0,0, 155,1,0,0, 156,1,0,0];
  }
  version(BigEndian) {
    auto efrom = EncodingScheme.create("utf-32be");
    ubyte[12] sample = [0,0,1,154, 0,0,1,155, 0,0,1,156];
  }
  const(ubyte)[] ub = cast(const(ubyte)[])sample;
  dchar dc = efrom.safeDecode(ub);
  assert(dc == 410);
  assert(ub.length == 8);
}


void main () {
  testUTF16();
  testUTF32();
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are watching all bug changes.</li>
      </ul>
    </body>
</html>