std.file and non-English filename in Windows

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Jan 1 11:36:51 UTC 2018


On Monday, January 01, 2018 10:47:51 Patrick Schluter via Digitalmars-d-
learn wrote:
> On Sunday, 31 December 2017 at 18:21:29 UTC, Domain wrote:
> > In Windows, exists, rename, copy will report file not exists
> > when you input non-English filename, such as Chinese 中文.txt
>
> It's unclear what your problem is but here a wild guess.
>
> Windows API's for Unicode use UTF-16 as far as I know. Strings in
> D are utf-8. So before calling win32 API function, they have to
> be transformed to wstring i.e. utf-16 strings.

std.file abstracts all of that away for you, and it does have at least some
tests that use Unicode characters, though I think that most of the functions
don't have tests that use Unicode characters. I would not have expected a
Unicode bug like this to be in std.file, but it's certainly possible.

It's also possible that the console needs to be set to UTF-8 or UTF-16 or
something, since the default often seems to cause problems for folks -
though unless the file names are coming from the command-line, I wouldn't
have expected that to be an issue. I do almost nothing with Windows though,
so I'm not very familiar with the ins and outs of that mess.

- Jonathan M Davis




More information about the Digitalmars-d-learn mailing list