code: function validateCode(code) {
    	if (!code) {
    		return 65533;
    	}
  
    	// 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 65533;
    	}
  
    	// rest of the basic multilingual plane
    	if (code <= 65535) {
    		return code;
    	}
  
    	return 65533;
    }
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