Skip to content

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

@mertcandav

Description

@mertcandav

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinginvestigation-neededInvestigation needed about issueruntimeRelated with std/runtime or compiled behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions