Bug 7648 – std.stdio expects file names to be encoded in CP_ACP on Windows instead of UTF-8

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2012-03-05T01:38:00Z
Last change time
2015-12-06T17:20:13Z
Assigned to
nobody
Creator
deep0125
Depends on
8643

Attachments

IDFilenameSummaryContent-TypeSize
1080FileAcc.7zsource and exeapplication/octet-stream65900

Comments

Comment #0 by deep0125 — 2012-03-05T01:38:28Z
Created attachment 1080 source and exe Can't open file. Look in the archive source: -----------------------main.d import std.stdio; int main(string[] argv) { auto file2 = File("Привет.txt"); return 0; } ---------------------------
Comment #1 by mk — 2012-03-10T16:21:07Z
(In reply to comment #0) > auto file2 = File("Привет.txt"); Can't test with this filename as I have no Russian support, but it works for me with accented characters. import std.stdio, std.stream; void main(char[][] args) { char[] filename; if (args.length==2) filename=args[1]; else filename="utfname-žlutý.txt"; writefln("filename: %s", filename); File file = new File(filename); } However, what doesn't work is reading UTF8 from the commandline (using chcp 65001): D:\devel\bugs>utfname filename: utfname-žlutý.txt D:\devel\bugs>utfname utfname-zluty.txt filename: utfname-zluty.txt D:\devel\bugs>utfname utfname-žlutý.txt Error: 1invalid UTF-8 sequence filename: OS Windows XP Czech
Comment #2 by deep0125 — 2012-03-11T07:20:56Z
(In reply to comment #1) > (In reply to comment #0) > > auto file2 = File("Привет.txt"); > > Can't test with this filename as I have no Russian support, but it works for me Easy, download attached archive and extract to disk.
Comment #3 by mk — 2012-03-13T15:27:03Z
(In reply to comment #2) > Easy, download attached archive and extract to disk. OK, tried, same error as you reported.
Comment #4 by Oleg.Kuporosov — 2012-05-03T00:07:53Z
It doesn't look as a bug. Would you please elaborate why do you think so? D itself (as source) is agnostic to Unicode version, but operation systems where the source will be compiled and then run - not a all. What I mean - you can have UTF8 source in Windows and even compile, but Windows itself (kernel, file systems, shell) is UTF16LE/ASCII only. The same time std.stdio doesn't promise to auto convert your UTF8 string to UTF16 stringZ, it even doesn't know which coding you are using. So suggestion is to close this bug. PS. Current std.stdio can't handle even UTF16LE (enhancement #8020), only ASCII names in Windows, workaround is to use ASCII only or std.stream or native Windows calls until probably new std.io (in hope it will support wstrings for names) will be finished and accepted into Phobos.
Comment #5 by verylonglogin.reg — 2012-07-06T00:27:11Z
(In reply to comment #1) > However, what doesn't work is reading UTF8 from the commandline (using chcp > 65001): Your program is written in (outdated) D1 so you are affected by Issue 1188.
Comment #6 by verylonglogin.reg — 2012-07-06T00:54:48Z
*** Issue 8020 has been marked as a duplicate of this issue. ***
Comment #7 by verylonglogin.reg — 2012-09-11T13:57:31Z
Comment #8 by github-bugzilla — 2012-09-16T20:45:24Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/e5e123854e28b759418791744402491d82840140 Partial Fix Issue 7648 - std.stdio expects file names to be encoded in CP_ACP on Windows instead of UTF-8 https://github.com/D-Programming-Language/phobos/commit/53a19c8d32610f5398a717a4e66a746211f5b7c9 Merge pull request #788 from denis-sh/partial-fix-Issue-7648 Partial fix Issue 7648
Comment #9 by github-bugzilla — 2013-04-17T13:13:08Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/c372571d1f868abd2294944b617f3863184462fe Add note about Issue 7648 to `std.stdio.File`. Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=7648 https://github.com/D-Programming-Language/phobos/commit/176976a57baf2505db894a314921dbaf8e347154 Merge pull request #1238 from denis-sh/add-note-about-Issue-7648 Add note about Issue 7648 to `std.stdio.File`.
Comment #10 by dlang-bugzilla — 2014-02-14T11:32:05Z
How about using CreateFile + windowsHandleOpen? https://github.com/D-Programming-Language/phobos/pull/1888
Comment #11 by github-bugzilla — 2014-07-12T02:17:15Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/2932b9e7e5ee7c6eb6057bef61ab6be6065ed013 Fix bug 7648 comment in `std.stdio.File` and add bug section to `std.file.slurp`. Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=7648 https://github.com/D-Programming-Language/phobos/commit/ec51209c9faa97d0598bb5401fff636fa3ba7124 Merge pull request #1653 from denis-sh/fix-bug-7648-comments Fix bug 7648 comment in `std.stdio.File` and add bug section to `std.file.slurp`.
Comment #12 by braddr — 2014-07-12T02:36:36Z
I'm reopening this since documentation != a fix. The commit comment incorrectly says fixed so github auto-closed the bug based on that.
Comment #13 by github-bugzilla — 2015-08-21T20:15:44Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/3a025da7c69f66b28c0eed53aa9ea1ccced01623 Cleanup for Issue 7648. Add Non-ASCII characters in filename for unittests. https://github.com/D-Programming-Language/phobos/commit/6df5d551fd8a21feef061483c226e7d9b26d6cd4 Merge pull request #3296 from aka-demik/Issue-7648 Cleanup for Issue 7648: std.stdio expects file names to be encoded in CP_ACP on Windows instead of UTF-8
Comment #14 by github-bugzilla — 2015-10-04T18:20:22Z
Comment #15 by verylonglogin.reg — 2015-12-06T17:20:13Z