您正位於 MDN Web Docs 的可編輯版本

以 MDN Web Docs 使用者身分檢視: https://developer.mozilla.org/zh-TW/docs/Web/API/USVString

我們的志工尚未將本文翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!
您也可以閱讀本文的 English (US) 版本。

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

文件標籤與貢獻者

最近更新: gregprice,