Re: [whatwg/encoding] Consider adding TextEncoder.containsLoneSurrogates() static (#174)

> But for our use case we still wouldn't want fatal, instead we would want something else, such as an API which returns the encoded Uint8Array (if the string is valid) or null (if the string contains unpaired surrogates). That would avoid the double iteration.

@Pauan Hmm, that doesn't sound really orthogonal to my `fatal` suggestion. What you're describing sounds more like a simple error handling of the result:

```js
let result;
try {
  result = strictEncoder.encode(someString);
} catch {
  result = null;
}
// here `result` is what you're describing, still without separate API or going through the string twice
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/encoding/issues/174#issuecomment-479229120

Received on Tuesday, 2 April 2019 22:16:10 UTC