-
-
Notifications
You must be signed in to change notification settings - Fork 658
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
[jvm] Pattern matching involving unicode #10720
Comments
This might be about the hashing being used. IIRC we determine a hash at compile-time and compare it to the one from run-time. |
Java treats each emoji to have length 2. So I guess that's where the issue comes from: function foo() return '😀 😀';
function bar() return 'abc';
function baz() return '名 字';
function main() {
trace(hashCode(foo()), ((cast foo():java.lang.Object).hashCode()), foo().length);
trace(hashCode(bar()), ((cast bar():java.lang.Object).hashCode()), bar().length);
trace(hashCode(baz()), ((cast baz():java.lang.Object).hashCode()), baz().length);
}
function hashCode(value:String) {
var h = 0;
if(value.length > 0) {
for(i in 0...value.length) {
h = 31 * h + value.charCodeAt(i);
}
}
return h;
} prints:
|
Java uses a modified UTF-8 encoding, described here. In particular, code points above |
Fortunately, I found a |
v4.2.5
this prints "yo" in nodejs and "meh" in jvm
The text was updated successfully, but these errors were encountered: