Search e01
One query across the encyclopedia, books, dictionary, papers, Wikidata and the developer library. Every hit carries its source.
6 results across 6 corpora for String.prototype.isWellFormed().
Developer library 6
Firefox 119 release notes for developers
hods for grouping the elements of an iterable are now supported (See [Firefox bug 1792650](https://bugzil.la/1792650) for more details.) - The String.prototype.isWellFormed() and String.prototype.toWellFormed() methods respectively can be used to check if a string contains well-formed Unicode text (i.e., contains no [lone surrogates](/docs/Web/JavaScript/Reference/Global_Objects/String#utf-16_characters_unicode_code_
String
, and are safe to be used with functions that do not deal with UTF-16 (such as `encodeURI()` or TextEncoder). You can check if a string is well-formed with the isWellFormed() method, or sanitize lone surrogates with the toWellFormed() method. On top of Unicode characters, there are certain sequences of Unicode characters that should be treated as one visual unit, known as a _grapheme cluster_. The most common case i
String.prototype.toWellFormed()
with all lone surrogates replaced with the Unicode replacement character U+FFFD. If `str` [is well formed](/docs/Web/JavaScript/Reference/Global_Objects/String/isWellFormed), a new string is still returned (essentially a copy of `str`). ## Description Strings in JavaScript are UTF-16 encoded. UTF-16 encoding has the concept of _surrogate pairs_, which is introduced in detail in the [UTF-16 characters, Unicode code
String.prototype.isWellFormed()
The **`isWellFormed()`** method of String values returns a boolean indicating whether this string contains any [lone surrogates](/docs/Web/JavaScript/Reference/Global_Objects/String#utf-16_characters_unicode_code_points_and_grapheme_clusters). ## Syntax ```js-nolint isWellFormed() ``` ### Parameters None. ### Return value Returns `true` if this string does not contain any lone surrogates, `false` otherwise. ##
encodeURIComponent()
rototype.toWellFormed(), which replaces lone surrogates with the Unicode replacement character (U+FFFD), to avoid this error. You can also use String.prototype.isWellFormed() to check if a string contains lone surrogates before passing it to `encodeURIComponent()`. ## Specifications ## Browser compatibility ## See also - decodeURI() - encodeURI() - decodeURIComponent()
encodeURI()
rototype.toWellFormed(), which replaces lone surrogates with the Unicode replacement character (U+FFFD), to avoid this error. You can also use String.prototype.isWellFormed() to check if a string contains lone surrogates before passing it to `encodeURI()`. ## Specifications ## Browser compatibility ## See also - decodeURI() - encodeURIComponent() - decodeURIComponent()