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

[core] SetClipboardText() UTF-8 issue for PLATFORM_WEB #3251

Closed
4 tasks done
ghost opened this issue Aug 19, 2023 · 0 comments · Fixed by #3257
Closed
4 tasks done

[core] SetClipboardText() UTF-8 issue for PLATFORM_WEB #3251

ghost opened this issue Aug 19, 2023 · 0 comments · Fixed by #3257
Labels
platform: Web Web platform

Comments

@ghost
Copy link

ghost commented Aug 19, 2023

Issue description

SetClipboardText() is not properly supporting UTF-8 string data on PLATFORM_WEB. E.g.: passing an unescaped char (like \n, \x0A, 0x0A) to it causes the program/game to crash on web.

Relevant parts of code: L2142-L2153 and L2150-L2151. I'll investigate further.

Environment

Platform: Web
Browser: Chromium
Version: 115.0.5790.170 (64-bit)
OS: Linux Mint 21.1 (64-bit)

Platform: Web
Browser: Firefox
Version: 115.1.0esr (64-bit)
OS: Linux Mint 21.1 (64-bit)

Code Example

Minimal reproduction code to test the issue:

int main(void) {
    InitWindow(800, 450, "test");
    SetTargetFPS(60);
    while (!WindowShouldClose()) {

        // Works
        if (IsKeyPressed(KEY_ONE))   SetClipboardText("1\\n2");

        // Crashes
        if (IsKeyPressed(KEY_TWO))   SetClipboardText("3\n4");
        if (IsKeyPressed(KEY_THREE)) SetClipboardText("\x35\x0A\x36");

        BeginDrawing();
        ClearBackground(RAYWHITE);
        EndDrawing();
    }
    CloseWindow();
    return 0;
}

Edit 1: updated code example for clarity.
Edit 2: added UTF-8 literals test to code example.

@raysan5 raysan5 added the platform: Web Web platform label Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Web Web platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant