MCPcopy Index your code
hub / github.com/nodejs/node / sanitizeUnpairedSurrogates

Function sanitizeUnpairedSurrogates

test/common/wpt.js:45–56  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

43
44// https://github.com/web-platform-tests/wpt/blob/b24eedd/resources/testharness.js#L3705
45function sanitizeUnpairedSurrogates(str) {
46 return str.replace(
47 /([\ud800-\udbff]+)(?![\udc00-\udfff])|(^|[^\ud800-\udbff])([\udc00-\udfff]+)/g,
48 function(_, low, prefix, high) {
49 let output = prefix || ''; // Prefix may be undefined
50 const string = low || high; // Only one of these alternates can match
51 for (let i = 0; i < string.length; i++) {
52 output += codeUnitStr(string[i]);
53 }
54 return output;
55 });
56}
57
58function codeUnitStr(char) {
59 return 'U+' + char.charCodeAt(0).toString(16);

Callers 1

addSubtestMethod · 0.85

Calls 1

codeUnitStrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…