- From: Mathias Bynens <notifications@github.com>
- Date: Mon, 08 Apr 2019 01:27:48 -0700
- To: whatwg/encoding <encoding@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 8 April 2019 08:29:22 UTC
With lookbehind support in JavaScript regular expressions, this functionality can trivially be implemented in userland: ```js function isWellFormed(string) { const reLoneSurrogate = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/; return !reLoneSurrogate.test(string); } ``` That might explain why it hadn't been considered for standardization before. Still, if this comes up often enough in standards discussions, that might be sufficient motivation to add something like a static `String.isWellFormed` method to the language. -- 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-480735701
Received on Monday, 8 April 2019 08:29:22 UTC