xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

JavaScript normalize function All In One

JavaScript normalize function All In One

image

Unicode string / Emoji string

国际化

String.prototype.normalize()

The normalize() method returns the Unicode Normalization Form of the string.

normalize() 方法返回字符串的 Unicode 规范化形式。

normalize()
normalize(form)

form Optional
One of "NFC", "NFD", "NFKC", or "NFKD", specifying the Unicode Normalization Form.
If omitted or undefined, "NFC" is used.

These values have the following meanings:

"NFC"
Canonical Decomposition, followed by Canonical Composition.

"NFD"
Canonical Decomposition.

"NFKC"
Compatibility Decomposition, followed by Canonical Composition.

"NFKD"
Compatibility Decomposition.

// 默认值 NFC
`曌`.length;
// 1
`曌`.normalize().length;
// 1

`曌`.normalize(`NFC`).length;
// 1

image

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize

Node.normalize()


https://developer.mozilla.org/en-US/docs/Web/API/Node/normalize

ConvolverNode.normalize


https://developer.mozilla.org/en-US/docs/Web/API/ConvolverNode/normalize

normalize-space

XPath

normalize-space( [string] )

https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/normalize-space

demos

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2023-02-17 21:27  xgqfrms  阅读(48)  评论(1编辑  收藏  举报