USVString

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