Bug 8643 – [snn] _wfopen and other non-standard wide-character functions fail with non-ASCII symbols

Status
NEW
Severity
major
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2012-09-11T13:15:52Z
Last change time
2024-12-07T13:32:06Z
Assigned to
No Owner
Creator
Denis Shelomovskii
Blocks
7648
Moved to GitHub: dmd#17245 →

Comments

Comment #0 by verylonglogin.reg — 2012-09-11T13:15:52Z
--- import std.file: write; import core.stdc.stdio: perror; extern (C) nothrow int _wrename(in wchar* from, in wchar* to); void main() { // write("1.txt", "123"); if(_wrename("1.txt"w.ptr, "2Ю.txt"w.ptr)) perror("Error renaming file"); } --- Output: --- Error renaming file: Invalid argument --- if: * there is no 1.txt file * there is 1.txt file * there is no 1.txt file and `write` is uncommented Output: --- Error renaming file: File exists --- if: * there is 1.txt file and `write` is uncommented
Comment #1 by verylonglogin.reg — 2012-09-11T13:27:31Z
These functions treats every UTF-16 codepoint as CP_ACP byte followed by zero byte (if second byte is non-zero, "Invalid argument" is returned). E.g. this will work: --- import std.file: write; import std.windows.charset: toMBSz; import core.stdc.stdio: perror; import std.exception: enforce; extern (C) nothrow int _wrename(in wchar* from, in wchar* to); void main() { write("1.txt", "123"); wchar[7] arr = "2#.txt\0"w; arr[1] = toMBSz("Ю")[0]; enforce(_wrename("1.txt"w.ptr, arr.ptr) == 0); } --- (still don't understand "File exists" output of original example in description)
Comment #2 by github-bugzilla — 2012-09-16T20:45:19Z
Comment #3 by sludwig — 2013-10-17T14:18:59Z
Increasing severity as this is really basic functionality. This was also reported as a DUB bug: https://github.com/rejectedsoftware/dub/issues/130
Comment #4 by verylonglogin.reg — 2013-10-17T22:59:12Z
(In reply to comment #3) > Increasing severity as this is really basic functionality. One can use `std.stream` which contains this functionality.
Comment #5 by verylonglogin.reg — 2013-10-18T02:34:42Z
Assigned to myself. Reassign is somebody feels he can do it faster.
Comment #6 by verylonglogin.reg — 2013-10-19T03:02:11Z
(In reply to comment #5) > Assigned to myself. Reassign is somebody feels he can do it faster. Sorry, this is not the issue I'm solving. Reset assignee to default and opened Issue 11298 which will allow Issue 7648 to be resolved without fixing this one.
Comment #7 by dlang-bugzilla — 2014-02-14T11:30:26Z
How about using CreateFile + windowsHandleOpen + fdopen? https://github.com/D-Programming-Language/phobos/pull/1888
Comment #8 by dlang-bugzilla — 2014-02-14T11:31:36Z
Sorry, meant to comment on issue 7648.
Comment #9 by robert.schadek — 2024-12-07T13:32:06Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17245 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB