依頼されたので調べてみたけど、Operaも実装がないっていうのにちょっと驚いた。
ブラウザ | Firefox | IE | IE | Opera | Google Chrome | Safari (Windows) |
---|---|---|---|---|---|---|
バージョン | 3.0.3 | 7.0.5730.13 | 6.0.2900.5512 | 9.52 | 0.2.149.30 | 3.1.2 |
JavaScriptエンジン | Tracemonkey | IEエンジン | IEエンジン | Operaエンジン | V8 | JavaScriptCore |
"b".localeCompare("a") | 1 | 1 | 1 | 1 | 1 | 1 |
"b".localeCompare("b") | 0 | 0 | 0 | 0 | 0 | 0 |
"b".localeCompare("c") | -1 | -1 | -1 | -1 | -1 | -1 |
"b".localeCompare("B") | -1 | -1 | -1 | 32 | 32 | -1 |
"b".localeCompare("à") | 1 | 1 | 1 | -126 | -126 | 1 |
"b" < "B" | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
V8のソースみるとまだ未実装って書いてある。
// ECMA-262 section 15.5.4.9 // // This function is implementation specific. For now, we do not // do anything locale specific. function StringLocaleCompare(other) { if (%_ArgumentsLength() === 0) return 0; var this_str = ToString(this); var other_str = ToString(other); return %StringLocaleCompare(this_str, other_str); }
ていうか、そもそもlocaleCompareって今回訊かれるまで存在を知らなかった。