Skip to content

zig rc: UTF-16 (LE) encoding is not supported #17557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kassane opened this issue Oct 16, 2023 · 1 comment
Open

zig rc: UTF-16 (LE) encoding is not supported #17557

kassane opened this issue Oct 16, 2023 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@kassane
Copy link
Contributor

kassane commented Oct 16, 2023

Zig Version

0.12.0-dev.935+a1e0b9979

Steps to Reproduce and Observed Behavior

cc: @squeek502

repo test: https://github.com/kassane/wolfssl (forked w/ zig build [v0.12.0-dev])

Tried add

lib.addWin32ResourceFile(.{
        .file = .{ .path = "wolfssl.rc" },
    });

Commands: zig build -DTests -DShared -Dtarget=native-windows (my host is Linux)

error: error(compilation): clang preprocessor failed with stderr:
fatal error: UTF-16 (LE) byte order mark detected in '/home/kassane/Documents/wolfssl/wolfssl.rc', but encoding is not supported

lib.addWin32ResourceFile(.{
        .file = .{ .path = "wolfssl.rc" },
        .flags = &.{"/c1200"},
    });
/home/kassane/Documents/wolfssl/wolfssl.rc:1:1: error: invalid command line option(s)
error: unsupported code page: utf16 (id=1200)

Expected Behavior

Works, equal to standalone test:

exe.addWin32ResourceFile(.{
.file = .{ .path = "res/zig.rc" },
.flags = &.{"/c65001"}, // UTF-8 code page
});
exe.rc_includes = switch (rc_includes) {
.any => .any,
.gnu => .gnu,
};

@kassane kassane added the bug Observed behavior contradicts documented or intended behavior label Oct 16, 2023
@squeek502
Copy link
Collaborator

squeek502 commented Oct 16, 2023

This is a known limitation due to the clang preprocessor not supporting UTF-16 files (and AFAIK no preprocessor outside of MSVC supports UTF-16 files).

The relevant resinator issue is squeek502/resinator#5

Since you're forking wolfssl, my suggestion would be to convert wolfssl.rc to UTF-8 (and resource.h too if necessary). This could actually be done via build.zig if you don't want to touch the files themselves (generate a converted file and pass the generated file to addWin32ResourceFile). There's no reason beyond Visual Studio generating the .rc file as UTF-16 that it needs to be UTF-16 (there's not even any non-ASCII characters in it).

I've also opened squeek502/resinator#6 but it wouldn't be a viable workaround for this .rc file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants