Home > Web Front-end > JS Tutorial > How to use normalize function

How to use normalize function

不言
Release: 2019-02-18 15:29:00
Original
9181 people have browsed it

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.

How to use normalize function

Let’s first take a look at the basic syntax of normalize()

string.normalize([form])
Copy after login

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(&#39;NFC&#39;) 
  c = a.normalize(&#39;NFD&#39;) 
  d = a.normalize(&#39;NFKC&#39;) 
  e = a.normalize(&#39;NFKD&#39;) 
    
  document.write(b +"<br>"); 
  document.write(c +"<br>"); 
  document.write(d +"<br>"); 
  document.write(e); 
    
</script> 
</body>
</html>
Copy after login

The output result is as follows:

php中文网
php中文网
php中文网
php中文网
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template