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

[Bug]: UTF-8 Encoding issue (on Windows) #43473

Open
Shadow-Devil opened this issue Oct 8, 2024 · 2 comments
Open

[Bug]: UTF-8 Encoding issue (on Windows) #43473

Shadow-Devil opened this issue Oct 8, 2024 · 2 comments
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug

Comments

@Shadow-Devil
Copy link
Contributor

Shadow-Devil commented Oct 8, 2024

Description

The following UTF-8 sequence is not correctly handled and it is also handled differently if it is received as a payload from http or put into ballerina source code:

import ballerina/http;
import ballerina/io;

service / on new http:Listener(9090) {
    resource function post test(@http:Payload string payload) returns string {
        io:println("Explicit: Kolkāta");
        io:println("From Payload: ", payload);
        return payload;
    }
}

The resulting output in the console and in the API response look like this:

Explicit: Kolk─üta
From Payload: Kolk├ä´┐¢ta

image

Steps to Reproduce

No response

Affected Version(s)

2201.10.1

OS, DB, other environment details and versions

Windows 11

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added the Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime label Oct 8, 2024
@Shadow-Devil
Copy link
Contributor Author

Maybe this is windows related, since on Choreo it is working as expected.

@Shadow-Devil Shadow-Devil changed the title [Bug]: UTF-8 Encoding issue [Bug]: UTF-8 Encoding issue (on Windows) Oct 8, 2024
@ThisaruGuruge
Copy link
Member

Hi @Shadow-Devil

I think this happens because the JVM uses a different encoding in Windows.

Try this out:

Add a new variable named JAVA_TOOL_OPTIONS in your environment variables, where the value should be -Dfile.encoding=UTF8.

Check this StackOverflow answer as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Projects
None yet
Development

No branches or pull requests

3 participants