USVString - Web APIs 编辑
A USVString
is a sequence of Unicode scalar values. This definition differs from that of DOMString
or the JavaScript String
type in that it always represents a valid sequence suitable for text processing, while the latter can contain surrogate code points. The USVString
type is generally found in APIs that perform text processing, while DOMString
is used by most other APIs.
When a USVString
is provided to JavaScript, it maps to the JavaScript primitive String
with the UTF-16 encoding of its sequence of Unicode scalar values.
When a Web API accepts a USVString
, the JavaScript value provided is first stringified, in the same way as for DOMString
. The resulting string is then further converted to USVString
by replacing any surrogate code points (or equivalently, any unpaired surrogate code units) with the Unicode "replacement character" U+FFFD (�).
Specifications
Specification | Status | Comment |
---|---|---|
Web IDL The definition of 'USVString' in that specification. | Candidate Recommendation | Initial definition of the USVString type itself. |
Web IDL | Candidate Recommendation | This defines how JavaScript values are converted to USVString and vice versa. |
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论