Issue 18789 - std.stdio messes up UTF conversions on output
Summary: std.stdio messes up UTF conversions on output
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: ag0aep6g
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2018-04-21 15:28 UTC by ag0aep6g
Modified: 2020-10-06 18:09 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ag0aep6g 2018-04-21 15:28:37 UTC
----
import std.stdio;
void main()
{   
    // converting to char
    {
        auto f = File("test.txt", "w");
        f.writeln("\U0001F608"w); // UTFException
    }
    
    // converting to wchar_t
    {
        auto f = File("test.txt", "w,ccs=UTF16LE");
        // from char
        f.writeln("ΓΆ"); // writes garbage
        f.writeln("\U0001F608"); // ditto
        // from wchar
        f.writeln("\U0001F608"w); // leads to ErrnoException
    }
}
----

PR follows.
Comment 1 ag0aep6g 2018-04-21 15:32:16 UTC
(In reply to ag0aep6g from comment #0)
> PR follows.

https://github.com/dlang/phobos/pull/6469
Comment 2 github-bugzilla 2018-04-29 17:56:00 UTC
Commit pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/d5cc4c5087a1819ac716cb5ea11d988fa667f822
fix conversion from wchar to char in LockingTextWriter.put

Fixes the easier part of issue 18789.
Comment 3 Dlang Bot 2020-09-17 22:23:00 UTC
@aG0aep6G updated dlang/phobos pull request #6469 "[WIP] fix issue 18789 - std.stdio messes up UTF conversions on output" mentioning this issue:

- fix conversion from wchar to wchar_t in LockingTextWriter.put
  
  This fixes issue 18789.

https://github.com/dlang/phobos/pull/6469
Comment 4 Dlang Bot 2020-10-06 17:17:32 UTC
dlang/phobos pull request #6469 "fix issue 18789 - std.stdio messes up UTF conversions on output" was merged into master:

- 41f78fc1e111323a5097a2f96d8e232cb27e01d1 by aG0aep6G:
  fix conversion from wchar to wchar_t in LockingTextWriter.put
  
  This fixes issue 18789.

- e7e75cf2343bee5bae24622ef8035cde159b6c52 by aG0aep6G:
  add the original test case of issue 18789
  
  ... to ensure that it doesn't throw any exceptions like it used to.

https://github.com/dlang/phobos/pull/6469
Comment 5 ag0aep6g 2020-10-06 18:09:37 UTC
(In reply to Dlang Bot from comment #4)
>   This fixes issue 18789.

Not sure why the bot didn't pick that up. Closing as fixed.