On Sunday, 5 May 2024 at 18:28:29 UTC, SimonN wrote:
My implementation for the message box is now:

According to [UTF-8 Everywhere](https://utf8everywhere.org/#windows), I shouldn't use `MessageBoxA` at all. The `A` means ANSI codepages, _not_ UTF-8. My above code _will_ show garbage output when there is some non-ASCII in the exception message.

Better: Convert to UTF-16 yourself and call `MessageBoxW`:

    version (Windows) {
        import core.sys.windows.windows;
        import std.conv;
        const wstring messageBody = wtext(/* ... */, "\0");
        MessageBoxW(null, messageBody.ptr, null, MB_ICONERROR);
        throw /* ... */;
    }

-- Simon

Reply via email to