blob: 489619f6ea0ca69d52aa3111037d214102bb65ab (
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
|
---
title: 'RangeError: argument is not a valid code point'
slug: Web/JavaScript/Reference/Errors/Not_a_codepoint
tags:
- Error
- Errors
- JavaScript
- RangeError
translation_of: Web/JavaScript/Reference/Errors/Not_a_codepoint
---
<div>{{jsSidebar("Errors")}}</div>
<p>JavaScript の例外 "Invalid code point" は、 {{jsxref("NaN")}} 値、負の整数 (-1)、 整数以外 (5.4)、 0x10FFFF より大きい数 (1114111) が {{jsxref("String.fromCodePoint()")}} で使用された場合に発生します。</p>
<h2 id="Message">メッセージ</h2>
<pre class="brush: js">RangeError: {0} is not a valid code point (Firefox)
RangeError: Invalid code point {0} (Chromium)
</pre>
<h2 id="Error_type">エラーの種類</h2>
<p>{{jsxref("RangeError")}}</p>
<h2 id="What_went_wrong">エラーの原因</h2>
<p>{{jsxref("String.fromCodePoint()")}} は、 {{jsxref("NaN")}} 値、負の整数 (-1)、 整数以外 (5.4)、 0x10FFFF より大きい数 (1114111) が渡されるとこのエラーを発生します。</p>
<p><a href="https://ja.wikipedia.org/wiki/%E7%AC%A6%E5%8F%B7%E7%82%B9">コードポイント</a>は、 Unicode 文字集合の値です。これは整数 <code>0</code> から <code>0x10FFFF</code> までの範囲です。</p>
<h2 id="Examples">例</h2>
<h3 id="Invalid_cases">無効なケース</h3>
<pre class="brush: js example-bad">String.fromCodePoint('_'); // RangeError
String.fromCodePoint(Infinity); // RangeError
String.fromCodePoint(-1); // RangeError
String.fromCodePoint(3.14); // RangeError
String.fromCodePoint(3e-2); // RangeError
String.fromCodePoint(NaN); // RangeError</pre>
<h3 id="Valid_cases">有効な場合</h3>
<pre class="brush: js example-good">String.fromCodePoint(42); // "*"
String.fromCodePoint(65, 90); // "AZ"
String.fromCodePoint(0x404); // "\u0404"
String.fromCodePoint(0x2F804); // "\uD87E\uDC04"
String.fromCodePoint(194564); // "\uD87E\uDC04"
String.fromCodePoint(0x1D306, 0x61, 0x1D307) // "\uD834\uDF06a\uD834\uDF07"
</pre>
<h2 id="See_also">関連情報</h2>
<ul>
<li>{{jsxref("String.fromCodePoint()")}}</li>
</ul>
|