Skip to content
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

ci/cd: calling WriteConsoleW function on GitHub Actions fails #107

Open
mertcandav opened this issue Jun 18, 2024 · 0 comments
Open

ci/cd: calling WriteConsoleW function on GitHub Actions fails #107

mertcandav opened this issue Jun 18, 2024 · 0 comments
Labels
investigation-needed Investigation needed about issue.

Comments

@mertcandav
Copy link
Member

What would you like to share?

After correction solving of the issue #34, I created Windows GitHub Actions workflows to use.

The Jule API and Jule standard library uses the WriteConsoleW function of Windows for writing to console. The WriteConsoleW function usually used in Unicode cases, uses UTF-16 encoding. Jule uses UTF-8 encoded strings by default which is supports Unicode characters also, therefore calls WriteConsoleW function after UTF-8 to UTF-16 conversion.

This operation works fine on our local test systems; on 2 different AMD64 Windows 10 and single ARM64 Windows 11, works as expected. On GitHub Actions with windows-latest, the WriteConsoleW function returns zero which is means failed.

I created a new workflow with simple C++ program and tested with to understand whether this problem relevant with Jule implementation.

That's my simple C++ program to test;

#include <iostream>
#include <windows.h>

int main() {
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    wchar_t text[] = {104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 0};
    WriteConsoleW(hConsole, text, 11, nullptr, nullptr);
    return 0;
}

And that's my compile command: clang++ -O0 --std=c++17 -o main.exe main.cpp -lshell32 -lkernel32

The test program above, writes hello world to the stdout handle. The variable text stores UTF-16 encoded hello world characters with NULL termination. Works as expected on local machines unlike GitHub Actions. On GitHub Actions, will not prints anything and failed.

Additional information

GitHub Actions uses UTF-8 by default. Printing with std::cout or std::wcout with UTF-8 encoded strings works and displayed fine, but std::wcout output is not displayed well with UTF-16 encoded strings.

As far as I tested, GitHub Actions's "UTF-8 by default" approach is not a problem. I tested on local machines with UTF-8 localization and calling WriteConsoleW function with UTF-16 encoded strings works and displayed as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation-needed Investigation needed about issue.
Projects
None yet
Development

No branches or pull requests

1 participant