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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

x.json2: incorrect Unicode emojis interpretation #20243

Closed
MCausc78 opened this issue Dec 21, 2023 · 0 comments 路 Fixed by #20247
Closed

x.json2: incorrect Unicode emojis interpretation #20243

MCausc78 opened this issue Dec 21, 2023 · 0 comments 路 Fixed by #20247
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@MCausc78
Copy link
Contributor

MCausc78 commented Dec 21, 2023

Describe the bug

Current encoder interprets Unicode emoji as spaces (giving [" "] as incorrect output)

Reproduction Steps

import x.json2

fn main() {
    assert json2.Any([
        json2.Any('馃拃')
    ]).json_str().bytes() == '["馃拃"]'.bytes()
}

Expected Behavior

Successful execution without errors

Current Behavior

test.v:4: FAIL: fn main.main: assert x.json2.Any([x.json2.Any('馃拃')]).json_str().bytes() == '['馃拃']'.bytes()
   left value: x.json2.Any([x.json2.Any('馃拃')]).json_str().bytes() = [91, 34, 32, 34, 93]
  right value: '['馃拃']'.bytes() = [91, 34, 240, 159, 146, 128, 34, 93]
V panic: Assertion failed...
v hash: c0321c8
C:/Users/mclr/AppData/Local/Temp/v_0/test.12033367665732342971.tmp.c:8391: at _v_panic: Backtrace
C:/Users/mclr/AppData/Local/Temp/v_0/test.12033367665732342971.tmp.c:18701: by main__main
C:/Users/mclr/AppData/Local/Temp/v_0/test.12033367665732342971.tmp.c:18812: by wmain
0049f3f8 : by ???
0049f55b : by ???
7ffa3fd753e0 : by ???

Possible Solution

Hint: Python json encodes it as ["\\ud83d\\udc80"]

Additional Information/Context

Used in discord.v button components

V version

V 0.4.3 ed754cf

Environment details (OS name and version, etc.)

Unrelated

Note

You can use the 馃憤 reaction to increase the issue's priority for developers.

Please note that only the 馃憤 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants