blob: 2fdfa2c8b9d50d9c150c46b90cb84f4428a003bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
---
title: Intl.Locale.prototype.caseFirst
slug: Web/JavaScript/Reference/Global_Objects/Intl/Locale/caseFirst
tags:
- Internationalization
- Intl
- JavaScript
- Property
- Prototype
- Reference
- プロパティ
- 国際化
translation_of: Web/JavaScript/Reference/Global_Objects/Intl/Locale/caseFirst
---
<div>{{JSRef}}</div>
<p><span class="seoSummary"><strong><code>Intl.Locale.prototype.caseFirst</code></strong> プロパティは、ロケールの照合規則に大文字・小文字を考慮するかどうかを返すアクセサプロパティです。</span></p>
<h2 id="Description" name="Description">解説</h2>
<p>ロケールの照合規則は、そのロケールでの文字列の並び順を決定するために用いられます。ロケールによっては、照合処理で文字の大文字・小文字を使用する場合があります。この追加ルールは、 {{jsxref("Locale", "Locale")}} の <code>caseFirst</code> プロパティで表現することができます。</p>
<p><code>caseFirst</code> プロパティには下記の表にある通り、3種類の値を指定することができます。</p>
<h3 id="caseFirst_values" name="caseFirst_values"><code>caseFirst</code> の値</h3>
<table class="standard-table">
<thead>
<tr>
<th scope="col">値</th>
<th scope="col">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>upper</code></td>
<td>大文字は小文字よりも前に並べられます。</td>
</tr>
<tr>
<td><code>lower</code></td>
<td>小文字は大文字よりも前に並べられます。</td>
</tr>
<tr>
<td><code>false</code></td>
<td>大文字・小文字で特別な並べ替えはしません。</td>
</tr>
</tbody>
</table>
<h2 id="Examples" name="Examples">例</h2>
<h3 id="Setting_the_caseFirst_value_via_the_locale_string" name="Setting_the_caseFirst_value_via_the_locale_string">ロケール文字列による <code>caseFirst</code> 値の設定</h3>
<p><a href="https://www.unicode.org/reports/tr35/" rel="noopener">Unicode ロケール文字列仕様書</a>では、 <code>caseFirst</code> が表す値は <code>kf</code> キーに対応します。 <code>kf</code> はロケール文字列の「拡張子サブタグ」として扱われます。これらのサブタグは、ロケールに関するデータを追加するもので、 <code>-u</code> 拡張を使用してロケール識別子に追加されます。つまり、 <code>caseFirst</code> の値は、 <code>Locale</code> コンストラクターに渡される初期のロケール識別子文字列に追加することができます。 <code>caseFirst</code> の値を追加するには、まず文字列に <code>-u</code> 拡張キーを追加します。次に、照合順序の型を追加することを示すために <code>-kf</code> 拡張キーを追加します。最後に、 <code>caseFirst</code> の値を文字列に追加します。</p>
<pre class="brush: js">let caseFirstStr = new Intl.Locale("fr-Latn-FR-u-kf-upper");
console.log(caseFirstStr.caseFirst); // "upper" と表示</pre>
<h3 id="Setting_the_caseFirst_value_via_the_configuration_object_argument" name="Setting_the_caseFirst_value_via_the_configuration_object_argument">構成オブジェクト引数による caseFirst の値の設定</h3>
<p>{{jsxref("Locale/Locale", "Intl.Locale")}} コンストラクターには、オプションで構成オブジェクトの引数があり、拡張の種類を渡すために使用することができます。構成オブジェクトの <code>caseFirst</code> プロパティを望みの <code>caseFirst</code> の値に設定し、コンストラクターに渡します。</p>
<pre class="brush: js">let caseFirstObj= new Intl.Locale("en-Latn-US", {caseFirst: "lower"});
console.log(us12hour.caseFirst); // "lower" と表示</pre>
<h2 id="Specifications" name="Specifications">仕様書</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">仕様書</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('ES Int Draft', '#sec-Intl.Locale.prototype.caseFirst')}}</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
<div>{{Compat("javascript.builtins.Intl.Locale.caseFirst")}}</div>
<h2 id="See_also" name="See_also">関連情報</h2>
<ul>
<li>{{jsxref("Locale", "Intl.Locale")}}</li>
<li><a href="https://github.com/unicode-org/cldr/blob/master/common/bcp47/collation.xml#L49">Unicode case first collation spec</a></li>
</ul>
|