22.1.3 Properties of the String Prototype Object
22.1.3.10 String.prototype.isWellFormed ( )
This method performs the following steps when called:
- Let O be ? RequireObjectCoercible(this value).
- Let S be ? ToString(O).
- Return IsStringWellFormedUnicode(S).
22.1.3.11 String.prototype.toWellFormed ( )
This method returns a String representation of this object with all leading surrogates and trailing surrogates that are not part of a surrogate pair replaced with U+FFFD (REPLACEMENT CHARACTER).
It performs the following steps when called:
- Let O be ? RequireObjectCoercible(this value).
- Let S be ? ToString(O).
- Let strLen be the length of S.
- Let k be 0.
- Let result be the empty String.
- Repeat, while k < strLen,
- Let cp be CodePointAt(S, k).
- If cp.[[IsUnpairedSurrogate]] is true, then
- Set result to the string-concatenation of result and 0xFFFD (REPLACEMENT CHARACTER).
- Else,
- Set result to the string-concatenation of result and UTF16EncodeCodePoint(cp.[[CodePoint]]).
- Set k to k + cp.[[CodeUnitCount]].
- Return result.