TypeScript String normalize() Method
Last Updated :
28 Feb, 2024
TypeScript string normalize() is an inbuilt method in Typescript, this method is used to return a Unicode normalization form if you pass a string. If the input by the user is not initially a string it will converted to a string first then the required method is applied.
Syntax
string.normalize(form: string): string
Parameters:
form: Here are the different Unicode normalization forms:
- NFC: Normalization Form Canonical Composition.
- NFD: Normalization Form Canonical Decomposition.
- NFKC: Normalization Form Compatibility Composition.
- NFKD: Normalization Form Compatibility Decomposition.
Return Value:
Return a string that contains the Unicode normalization form of the form(i.e. input value).
Example 1: To demonstrate the basic use of normalize() method in TypeScript.
Javascript
let str: string = "Geeks For Geeks" ;
let str1: string = str.normalize( 'NFC' );
let str2: string = str.normalize( 'NFD' );
let str3: string = str.normalize( 'NFKC' );
let str4: string = str.normalize( 'NFKD' );
console.log(str1, str2, str3, str4);
|
Output:
Geeks For Geeks Geeks For Geeks Geeks For Geeks Geeks For Geeks
Example 2: To demonstrate the basic use of normalize() method in TypeScript.
Javascript
let str: string = "GeeksForGeeks" ;
let str1: string = str.normalize( 'NFC' );
let str2: string = str.normalize( 'NFD' );
let str3: string = str.normalize( 'NFKC' );
let str4: string = str.normalize( 'NFKD' );
console.log(str1);
console.log(str2);
console.log(str3);
console.log(str4);
|
Output:
GeeksForGeeks
GeeksForGeeks
GeeksForGeeks
GeeksForGeeks
Share your thoughts in the comments
Please Login to comment...