[Issue 15293] New: File().byLine().map!toUpper throws UnicodeException at src\rt\util\utf.d(290): invalid UTF-8 sequence on pure ASCII file
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Nov 5 12:25:27 PST 2015
https://issues.dlang.org/show_bug.cgi?id=15293
Issue ID: 15293
Summary: File().byLine().map!toUpper throws
UnicodeException at src\rt\util\utf.d(290): invalid UTF-8
sequence on pure ASCII file
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: heiko.honrath at web.de
Created attachment 1561
--> https://issues.dlang.org/attachment.cgi?id=1561&action=edit
ASCII-textfile which throws UTF8 exception
File().byLine().map!toUpper throws UnicodeException at src\rt\util\utf.d(290):
invalid UTF-8 sequence
on pure ASCII file
.map!toLower throws at a different location with the same file
If neither toLower nor toUpper are used, the file is read completely.
program generator.d:
module generator;
// 2015-11-05
// dmd2.069
// built with: rdmd --build-only --force -version=WindowsXP -version=Unicode
-release -O generator.d
// to reproduce run: generator gentest.txt
import std.stdio, std.algorithm, std.string, std.format;
void main(string[] args) {
int line_number = 1;
auto gen = File(args.length > 1 ? args[1] : "gentest.txt")
.byLine()
.map!chomp
.map!toUpper
//~ .map!toLower
.map!(line => format("Line %4s: %s", line_number++, line));
writefln("%-(%s\n%)", gen);
}
--
More information about the Digitalmars-d-bugs
mailing list