Scratch-vm: Hiragana and Katakana are equal!?

Created on 24 Aug 2018  ·  10Comments  ·  Source: LLK/scratch-vm

Expected Behavior

They shouldn't be equal. It's not capitalization, and they are different letters.

Actual Behavior

あ = ア

Steps to Reproduce

Use block <(あ) = (ア)>

Operating System and Browser

Windows 10, Firefox 61.0.2

bug help wanted localization needs-triage

Most helpful comment

@joker314 @towerofnix @Kenny2github I also found why you can't reproduce - It is a problem when you use Firefox in Japanese. The second argument of localeCompare is missing, so it uses your browser's language first.

Example:
When I ran "あ".localeCompare("ア","en"), it returned -1.
But when I ran "あ".localeCompare("ア","ja") it returned 0

I set the browser language to Japanese, so the default is latter one.
You use English one, don't you? Then the default is former one.

What I mean, in other words:
Use Japanese computer to reproduce this.

All 10 comments

I can definitely say this - scratch-vm/src/util/cast.js Lie 121
It is localeCompare that makes the problem.

@apple502j you say "definitely", but "あ".localeCompare("ア") results in -1, which is not 0 -- a sign of inequality. Do you have some evidence to suggest the contrary?

Unable to reproduce with Chrome on Windows on https://beta.scratch.mit.edu. Upon clicking, the block shows a bubble with the text "false".

@joker314 Likewise here on Firefox 62.0b19 / Linux:

The "=" block with the appropriate inputs and a "false" output bubble

Chrome 68.0.3440.106 Windows 10.0.17134.228
image

@joker314 @towerofnix @Kenny2github I also found why you can't reproduce - It is a problem when you use Firefox in Japanese. The second argument of localeCompare is missing, so it uses your browser's language first.

Example:
When I ran "あ".localeCompare("ア","en"), it returned -1.
But when I ran "あ".localeCompare("ア","ja") it returned 0

I set the browser language to Japanese, so the default is latter one.
You use English one, don't you? Then the default is former one.

What I mean, in other words:
Use Japanese computer to reproduce this.

https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/String.html#localeCompare()

While this method is intended to handle the comparison in a locale-specific way, the ActionScript 3.0 implementation does not produce a different result from other string comparisons such as the equality (==) or inequality (!=) operators.

I believe it's the same as < and >, because ECMA prescribes that as the fallback when locale-based sorting is unsupported. However, I might be completely mistaken!

/cc @chrisgarrity

/cc @kchadha

@thisandagain Question: Can't it be normal compare?
why localeCompare?

Was this page helpful?
0 / 5 - 0 ratings