code: function validateCode(code) {
    if (!code) {
      return invalid;
    }
  
    // line feed becomes generic whitespace
    if (code === 10) {
      return 32;
    }
  
    // ASCII range. (Why someone would use HTML entities for ASCII characters I don't know, but...)
    if (code < 128) {
      return code;
    }
  
    // code points 128-159 are dealt with leniently by browsers, but they're incorrect. We need
    // to correct the mistake or we'll end up with missing € signs and so on
    if (code <= 159) {
      return controlCharacters[code - 128];
    }
  
    // basic multilingual plane
    if (code < 55296) {
      return code;
    }
  
    // UTF-16 surrogate halves
    if (code <= 57343) {
      return invalid;
    }
  
    // rest of the basic multilingual plane
    if (code <= 65535) {
      return code;
    } else if (!codePointSupport) {
      return invalid;
    }
  
    // supplementary multilingual plane 0x10000 - 0x1ffff
    if (code >= 65536 && code <= 131071) {
      return code;
    }
  
    // supplementary ideographic plane 0x20000 - 0x2ffff
    if (code >= 131072 && code <= 196607) {
      return code;
    }
  
    return invalid;
  }
docs: some code points are verboten. If we were inserting HTML, the browser would replace the illegal code points with alternatives in some cases - since we're bypassing that mechanism, we need to replace them ourselves  Source: http://en.wikipedia.org/wiki/Character_encodings_in_HTML#Illegal_characters /* istanbul ignore next