Home >Web Front-end >JS Tutorial >How to use normalize function
string.normalize() is a built-in function in How to use normalize function, which is used to return the Unicode format of the given input string. If the given input is not a string, then first it will be converted to a string and then the function will work. Let's take a look at the specific usage of the normalize function.
Let’s first take a look at the basic syntax of normalize()
string.normalize([form])
The parameters here are in the form of multiple types:
NFC: Canonical Composition.
NFD: Normalized formal norm decomposition.
NFKC: Standardized Form Compatibility Composition.
NFKD: Normalized form compatibility decomposition.
These illustrate the Unicode normalization table.
Let’s look at a specific example
The code is as follows
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script> var a = "php中文网"; b = a.normalize('NFC') c = a.normalize('NFD') d = a.normalize('NFKC') e = a.normalize('NFKD') document.write(b +"<br>"); document.write(c +"<br>"); document.write(d +"<br>"); document.write(e); </script> </body> </html>
The output result is as follows:
php中文网 php中文网 php中文网 php中文网
This article ends here, For more exciting content, you can pay attention to other related column tutorials on the PHP Chinese website! ! !
The above is the detailed content of How to use normalize function. For more information, please follow other related articles on the PHP Chinese website!