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

Error when tracing an unicode character (codepoints > 0xFFFF) #54

Open
ylazy opened this issue Sep 7, 2024 · 7 comments
Open

Error when tracing an unicode character (codepoints > 0xFFFF) #54

ylazy opened this issue Sep 7, 2024 · 7 comments

Comments

@ylazy
Copy link

ylazy commented Sep 7, 2024

Hi!

Please view this issue.

trace(String.fromCharCode(0x1F60A));

image

I thought it's a vscode issue but if it's ok with other languages then it could be an as3mxml extension issue or a compiler/runtime issue?
I don't understand how as3mxml connecting trace statements to the vscode's debug console so I cannot determine where the problem is.

Please help!

Thank you!

@joshtynjala joshtynjala transferred this issue from BowlerHatLLC/vscode-as3mxml Sep 9, 2024
@joshtynjala
Copy link
Member

The relevant code in vscode-swf-debug is here:

https://github.com/BowlerHatLLC/vscode-swf-debug/blob/c5455c0/swf-debug-adapter/src/main/java/com/as3mxml/vscode/SWFDebugSession.java#L285-L299

@joshtynjala
Copy link
Member

I spent a little time debugging.

I confirmed that I can successfully display unicode characters in the debug console, if I hard-code them in the Java code.

The value of traceEvent.information appears to be wrong, so it seems to be a bug in the royale-compiler debugger module (or possibly in the Flash/AIR runtime). I'm not sure how to resolve.

@joshtynjala
Copy link
Member

I've determined that when the Java debugger code reads the bytes received from AIR, it seems to be getting 0xF60A instead of 0x1F60A. It appears that something in AIR is truncating the upper bytes.

Then, I discovered this:

trace(String.fromCharCode(0x1F60A).charCodeAt(0).toString(16)); // f60a

@ylazy
Copy link
Author

ylazy commented Feb 22, 2025

trace(String.fromCharCode(0x1F60A).charCodeAt(0).toString(16), String.fromCharCode(0x1F60A).length);

AIR 32.0.0.116 output: f60a 1
AIR 51.1.3.7 output: d83d 2

In AIR 50.2.4.5+:

AIR-7035: String.fromCharCode() should support all unicode code points

and we have to wait for AIR 52 to use codePointAt instead of charCodeAt

@ylazy
Copy link
Author

ylazy commented Feb 22, 2025

But I guess String.fromCharCode and string.charCodeAt are not related to this issue. You can try this:

trace("😊".length);

output 2 for both AIR 32 and AIR 51

@ylazy
Copy link
Author

ylazy commented Feb 22, 2025

More test:

AIR 32:

X.File.fromString("😊", X.File.applicationDirectory.resolvePath("testUTF16.air32.txt"));

AIR 51:

X.File.fromString("😊", X.File.applicationDirectory.resolvePath("testUTF16.air51.txt"));

Comparing the output file, I can see the same character.

Image

Image

So I think the compiler has been encoded the character correctly.

@ylazy
Copy link
Author

ylazy commented Feb 22, 2025

Hi @joshtynjala I finally found out an useful info.

Using Adobe Scout I got this trace output for trace("😊"); (the last line)

Image

Copying the last line to VSCode:

Image

I saw the original smiley:

Image

This means the trace function has successfully push out the smiley character. So I think the Air side is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants