digitalmars.D.bugs - [Issue 11374] New: Wrong UTF-8 decoding when calling File.readln(buf) with typeof(buf) == string.
- d-bugmail puremagic.com (58/58) Oct 28 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11374
- d-bugmail puremagic.com (10/10) Oct 28 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11374
- d-bugmail puremagic.com (13/14) Oct 29 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11374
- d-bugmail puremagic.com (11/11) Oct 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11374
http://d.puremagic.com/issues/show_bug.cgi?id=11374 Summary: Wrong UTF-8 decoding when calling File.readln(buf) with typeof(buf) == string. Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: joanbrugueram gmail.com I'm sorry if this is not really a bug but just some ultra-obscure quirk. Anyway, doing something like: string buf; stdin.readln(buf); Appears to work, but seems to decode some characters wrong (consistently). Using "char[] buf;" or "stdin.readln()" both work. Here's a more complete test case: *************************************************************** import std.stdio; void main() { ubyte[] weirdcharacterbytes = [0xf0, 0x90, 0xa4, 0x80]; string weirdcharacter = cast(string)weirdcharacterbytes; { auto f = File("weirdcharacter.txt", "wb"); f.rawWrite(weirdcharacterbytes); } { auto f = File("weirdcharacter.txt", "r"); string s = f.readln(); writeln(s == weirdcharacter ? "PASS" : "FAIL"); } { auto f = File("weirdcharacter.txt", "r"); char[] s; f.readln(s); writeln(s == weirdcharacter ? "PASS" : "FAIL"); } { auto f = File("weirdcharacter.txt", "r"); string s; f.readln(s); writeln(s == weirdcharacter ? "PASS" : "FAIL"); } } *************************************************************** PASS PASS FAIL *************************************************************** Thanks. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 28 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11374 Martin Krejcirik <mk krej.cz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mk krej.cz Your example doesn't compile in the git-head. See bug 10517. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 28 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11374Your example doesn't compile in the git-head. See bug 10517.Thank you, it appears that this bug has indeed been fixed. Also, this may sound like a rant or blaming someone else, and it very likely is, but the fact that the source link in the Phobos 2.063.2 documentation points to the prerelease version didn't help (obvious in hindsight, but no wonder I couldn't figure out which overload was being called and gave up). Also, I did indeed run a bugzilla search for 'readln', but the default filter doesn't display closed bugs, so I also couldn't find the closed bug you linked. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 29 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11374 Martin Krejcirik <mk krej.cz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE *** This issue has been marked as a duplicate of issue 10517 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 30 2013