From discussion in IRC. The specific issue that came up was how to convert a Zig String to a Windows API expecting a UTF-16 formatted string like [*c]c_ushort.
Usage would resemble:
const W = std.unicode.utf16leStringLiteral;
FooWindowsFunc(W("string literal"))
Should be closed by cf38ce970.
const std = @import("std");
const W = std.unicode.utf8ToUtf16LeStringLiteral;
const c = @cImport({
@cDefine("_NO_CRT_STDIO_INLINE", "1");
@cInclude("stdio.h");
});
usingnamespace std.os.windows;
extern "user32" fn MessageBoxW(hWnd: ?HANDLE, lpText: ?LPCWSTR, lpCaption: ?LPCWSTR, uType: UINT) callconv(.Stdcall) c_int;
pub fn main() void {
_ = c.wprintf(W("Hello World\n"));
_ = c.wprintf(W("Bonjour %s - %ls\n"), W("String"), W("Strange"));
_ = c.wprintf(W("H\n"));
_ = c.wprintf(W("H"));
_ = MessageBoxW(null, W("饜惙Content饜惙"), W("Turtle"), 0);
}
Most helpful comment
Should be closed by cf38ce970.