From bf8e099b9c8b3c60d60b3712b4fc97b052c39887 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:23 +0200 Subject: convert content to md --- .../global_objects/string/fromcodepoint/index.md | 98 +++++++++------------- 1 file changed, 41 insertions(+), 57 deletions(-) (limited to 'files/fr/web/javascript/reference/global_objects/string/fromcodepoint') diff --git a/files/fr/web/javascript/reference/global_objects/string/fromcodepoint/index.md b/files/fr/web/javascript/reference/global_objects/string/fromcodepoint/index.md index 81cf698e35..86b4cc9888 100644 --- a/files/fr/web/javascript/reference/global_objects/string/fromcodepoint/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/fromcodepoint/index.md @@ -11,42 +11,39 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/String/fromCodePoint original_slug: Web/JavaScript/Reference/Objets_globaux/String/fromCodePoint --- -
{{JSRef}}
+{{JSRef}} -

La méthode statique String.fromCodePoint() renvoie une chaîne de caractères créée à partir d'un suite de codets.

+La méthode statique **`String.fromCodePoint()`** renvoie une chaîne de caractères créée à partir d'un suite de codets. -
{{EmbedInteractiveExample("pages/js/string-fromcodepoint.html")}}
+{{EmbedInteractiveExample("pages/js/string-fromcodepoint.html")}} -

Syntaxe

+## Syntaxe -
String.fromCodePoint(num1[, ...[, numN]])
+ String.fromCodePoint(num1[, ...[, numN]]) -

Paramètres

+### Paramètres -
-
num1, ..., numN
-
Une séquence de codets (code points).
-
+- `num1, ..., numN` + - : Une séquence de codets (_code points_). -

Valeur de retour

+### Valeur de retour -

Une chaîne de caractères créée à partir de la séquence de codets indiquée.

+Une chaîne de caractères créée à partir de la séquence de codets indiquée. -

Exceptions

+### Exceptions - +- Une exception {{jsxref("Erreurs/Not_a_codepoint","RangeError")}} est renvoyée si un codet (Unicode) invalide est utilisé (par exemple, on pourra avoir "RangeError: NaN is not a valid code point"). -

Description

+## Description -

fromCodePoint() étant une méthode statique de {{jsxref("String")}}, elle doit toujours être utilisée avec la syntaxe String.fromCodePoint(), plutôt qu'avec une méthode d'un objet {{jsxref("String")}} qui aurait été créé.

+`fromCodePoint()` étant une méthode statique de {{jsxref("String")}}, elle doit toujours être utilisée avec la syntaxe `String.fromCodePoint()`, plutôt qu'avec une méthode d'un objet {{jsxref("String")}} qui aurait été créé. -

Exemples

+## Exemples -

Utiliser fromCodePoint()

+### Utiliser `fromCodePoint()` -
String.fromCodePoint(42);       // "*"
+```js
+String.fromCodePoint(42);       // "*"
 String.fromCodePoint(65, 90);   // "AZ"
 String.fromCodePoint(0x404);    // "\u0404"
 String.fromCodePoint(0x2F804);  // "\uD87E\uDC04"
@@ -59,50 +56,37 @@ String.fromCodePoint(-1);       // RangeError
 String.fromCodePoint(3.14);     // RangeError
 String.fromCodePoint(3e-2);     // RangeError
 String.fromCodePoint(NaN);      // RangeError
-
+``` -

Comparaison avec fromCharCode()

+### Comparaison avec `fromCharCode()` -

La méthode {{jsxref("String.fromCharCode()")}} ne peut pas renvoyer les caractères de l'intervalle 0x010000 à 0X10FFFF avec un seul codet, il est nécessaire de lui fournir la paire décomposée (surrogate pair) pour obtenr un tel caractère :

+La méthode {{jsxref("String.fromCharCode()")}} ne peut pas renvoyer les caractères de l'intervalle 0x010000 à 0X10FFFF avec un seul codet, il est nécessaire de lui fournir la paire décomposée (_surrogate pair_) pour obtenr un tel caractère : -
String.fromCharCode(0xD83C, 0xDF03); // émoji « nuit étoilée »
-String.fromCharCode(55356, 57091);   // équivalent en notation décimale
+```js +String.fromCharCode(0xD83C, 0xDF03); // émoji « nuit étoilée » +String.fromCharCode(55356, 57091); // équivalent en notation décimale +``` -

String.fromCodePoint(), en revanche, peut renvoyer les caractères qui s'expriment sur plus d'un codet de 16 bits grâce à leur codet « simple » :

+`String.fromCodePoint()`, en revanche, peut renvoyer les caractères qui s'expriment sur plus d'un codet de 16 bits grâce à leur codet « simple » : -
String.fromCodePoint(0x1F303); // ou 127747 en notation décimale
+```js +String.fromCodePoint(0x1F303); // ou 127747 en notation décimale +``` -

Spécifications

+## Spécifications - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES2015', '#sec-string.fromcodepoint', 'String.fromCodePoint')}}{{Spec2('ES2015')}}Définition initiale
{{SpecName('ESDraft', '#sec-string.fromcodepoint', 'String.fromCodePoint')}}{{Spec2('ESDraft')}}
+| Spécification | État | Commentaires | +| ---------------------------------------------------------------------------------------------------- | ---------------------------- | ------------------- | +| {{SpecName('ES2015', '#sec-string.fromcodepoint', 'String.fromCodePoint')}} | {{Spec2('ES2015')}} | Définition initiale | +| {{SpecName('ESDraft', '#sec-string.fromcodepoint', 'String.fromCodePoint')}} | {{Spec2('ESDraft')}} | | -

Compatibilité des navigateurs

+## Compatibilité des navigateurs -

{{Compat("javascript.builtins.String.fromCodePoint")}}

+{{Compat("javascript.builtins.String.fromCodePoint")}} -

Voir aussi

+## Voir aussi - +- {{jsxref("String.fromCharCode()")}} +- {{jsxref("String.prototype.charAt()")}} +- {{jsxref("String.prototype.codePointAt()")}} +- {{jsxref("String.prototype.charCodeAt()")}} -- cgit v1.2.3-54-g00ecf