From f2903b723dfde64afba032ed2862627e4f5f7b14 Mon Sep 17 00:00:00 2001 From: aG0aep6G Date: Mon, 21 Sep 2020 21:12:10 +0200 Subject: [PATCH] add original test case of issue 18789 Fixes issue 18789. --- std/stdio.d | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/std/stdio.d b/std/stdio.d index 308dd8291ab..380224815a2 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -3710,6 +3710,26 @@ void main() assert(std.file.readText!string(deleteme).stripLeft("\uFEFF") == text(strs)); } +@safe unittest // https://issues.dlang.org/show_bug.cgi?id=18789 +{ + static import std.file; + auto deleteme = testFilename(); + scope(exit) std.file.remove(deleteme); + // converting to char + { + auto f = File(deleteme, "w"); + f.writeln("\U0001F608"w); // UTFException + } + // converting to wchar_t + { + auto f = File(deleteme, "w,ccs=UTF16LE"); + // from char + f.writeln("รถ"); // writes garbage + f.writeln("\U0001F608"); // ditto + // from wchar + f.writeln("\U0001F608"w); // leads to ErrnoException + } +} @safe unittest {