[Bug 138] New: std.enconding: EncodingSchemeUtf16Native and EncodingSchemeUtf32Native invalid splicing
via D.gnu
d.gnu at puremagic.com
Sat Jun 14 11:45:55 PDT 2014
http://bugzilla.gdcproject.org/show_bug.cgi?id=138
Bug ID: 138
Summary: std.enconding: EncodingSchemeUtf16Native and
EncodingSchemeUtf32Native invalid splicing
Product: GDC
Version: development
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: Normal
Component: libgphobos
Assignee: ibuclaw at gdcproject.org
Reporter: ketmar at ketmar.no-ip.org
Created attachment 70
--> http://bugzilla.gdcproject.org/attachment.cgi?id=70&action=edit
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();
}
--
You are receiving this mail because:
You are watching all bug changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20140614/260f934c/attachment.html>
More information about the D.gnu
mailing list