packages/fbjs/src/unicode/UnicodeUtilsExtra.js
function phpEscape(s) {
  var result = '"';
  for (let cp of UnicodeUtils.getCodePoints(s)) {
    let special = specialEscape[cp];
    if (special !== undefined) {
      result += special;
    } else if (cp >= 0x20 && cp <= 0x7e) {
      result += String.fromCodePoint(cp);
    } else if (cp <= 0xFFFF) {
      result += '\\u{' + zeroPaddedHex(cp, 4) + '}';
    } else {
      result += '\\u{' + zeroPaddedHex(cp, 6) + '}';
    }
  }
  result += '"';
  return result;
}
function phpEscape(s) {
  var result = '"';
  for (let cp of UnicodeUtils.getCodePoints(s)) {
    let special = specialEscape[cp];
    if (special !== undefined) {
      result += special;
    } else if (cp >= 0x20 && cp <= 0x7e) {
      result += String.fromCodePoint(cp);
    } else if (cp <= 0xFFFF) {
      result += '\\u{' + zeroPaddedHex(cp, 4) + '}';
    } else {
      result += '\\u{' + zeroPaddedHex(cp, 6) + '}';
    }
  }
  result += '"';
  return result;
}
function phpEscape ( s ) { var result = '"' ; for ( let cp of UnicodeUtils . getCodePoints ( s ) ) { let special = specialEscape [ cp ] ; if ( special !== undefined ) { result += special ; } else if ( cp >= 0x20 && cp <= 0x7e ) { result += String . fromCodePoint ( cp ) ; } else if ( cp <= 0xFFFF ) { result += '\\u{' + zeroPaddedHex ( cp , 4 ) + '}' ; } else { result += '\\u{' + zeroPaddedHex ( cp , 6 ) + '}' ; } } result += '"' ; return result ; }
Returns a double-quoted PHP string with all non-printable and
non-US-ASCII sequences escaped.

@param {string} str Valid Unicode string
@return {string}    Double-quoted string with Unicode sequences escaped
Returns a double - quoted PHP string with all non - printable and non - US - ASCII sequences escaped .